Reputation: 6973
Earlier, I created my entities this way:
Entity entity = new Entity("Person", personName);
. Which means the ID/Name of this entity will be personName.
Now, I've decided to use Objectify. So I've created a Person.java
class to represent this entity.
My question: how can I retrieve the key (either a com.google.appengine.api.datastore.Key
or the raw string representation) of the entity using Objectify? Previously, I was able to simply do a personEntity.getKey()
. But I'm still trying to figure out how to do that with Objectify after using it to wrap around the Low Level Datastore API.
Upvotes: 1
Views: 659
Reputation: 13556
Objectify's Key<?>
has a method getRaw()
which will get you the low-level Key
. Check the javadocs.
If you are using the latest 4.0 code, try Key.create(yourEntityPOJO).getRaw()
.
Upvotes: 0