4

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));
ryan
  • 2,687
  • 1
  • 29
  • 38
Erick Fleming
  • 1,270
  • 1
  • 9
  • 17

2 Answers2

3

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

Erick Fleming
  • 1,270
  • 1
  • 9
  • 17
0

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
  • 301
  • 2
  • 9
  • 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. – Erick Fleming Jun 15 '09 at 23:29