views:

259

answers:

2

I'm using the low-level API in Google App Engine for Java and want to get all the child entities of a particular parent entity:

Given the following graph:

Parent (1)
|
+ --- Child A (2)
|    |
|    + --- Child B (3)
|
+ --- Child A (4)

I want a list like the following

[Child A (2), Child B (3), Child A (4)]

Here is my best attempt:

Entity pe = new Entity("parent");

Entity c1 = new Entity("childA", pe.getKey());
Entity c2 = new Entity("childB", c1.getKey());
Entity c3 = new Entity("childA", pe.getKey());

// storage code left out for brevity

Key parentKey = KeyFactory.createKey(null, "parent", 1);

// According to documentation this should work (but does not)
PreparedQuery q = datastore.prepare(new Query(parentKey));
A: 

Wouldn't getKey() be a method, not a property (ent.getKey(), not ent.getKey?

Also, isn't parentKey the same as pe.getKey()?

Fat Lotus
Thank you, I fixed the typo.As far as pe.getKey(), I only have the Id number when the query is actually performed, so I thought I would include how I got the key.
efleming969
+1  A: 

I found out that this is a known bug in the local development server. When uploading to google it works fine

efleming969