david
david

Reputation: 2142

Google AppEngine (GAE) - complete object key

I have a list of child entities in my datastore. I query the datastore to get their id and name to show them in a listbox. (I send the long id) When the user selects an entity I need to get the entity info. I'm using this:

Key parentKey = KeyFactory.createKey(Parent.class.getSimpleName(), parentLongKey);
Key childKey = KeyFactory.createKey(parentKey, Child.class.getSimpleName(), childLongKey);
manager.getObjectById(Child.class, childKey);

and it works, but if the child class has it own child class I'll need to create the parent key, the child key and the subchild key???

There is a way to get some id type enough to query the child entity without creating the parents entities???

I tried using the string but has the same problem. I tried the .toString key version and it has a similar problem

Thx a lot!

Upvotes: 0

Views: 205

Answers (1)

Nick Johnson
Nick Johnson

Reputation: 101149

Use the stringified version of the whole key, using keyToString and stringToKey.

Upvotes: 3

Related Questions