steff_bdh
steff_bdh

Reputation: 1188

How to reference the default Id property of an entity on google app engine

If i've annotated a string variable in my JDO to be used as the id e.g.

@Id
private String nameOfId;

And in the appengine's console it's named as 'NAME/ID', what do I use to get the property

Note: For my queries, I'm using the datastore's query and not the entity manager, this means a collection of entities are returned to me and i've to get it's properties using, 'getProperty("propertyName")'

Also Note: ive tried the following names

getProperty("id");
getProperty("Id");
getProperty("name");
getProperty("NAME");
getProperty("NAME/ID");
getProperty("nameOfId");

none of these worked, I would just like to know what text I need to put as my argument for the getProperty method

Upvotes: 0

Views: 71

Answers (1)

Dan Sanderson
Dan Sanderson

Reputation: 2111

The ID is not a property of the entity, it is a part of the entity key. It appears in the Console as a column only to help identify the entity.

To get the string ID from a com.google.appengine.api.datastore.Entity, call its getKey() method to return a Key, and call the key's getName() method.

Upvotes: 3

Related Questions