我在 Google App Engine for Java 中使用低级 API,并希望获取特定父实体的所有子实体:
给定下图:
Parent (1)
|
+ --- Child A (2)
| |
| + --- Child B (3)
|
+ --- Child A (4)
我想要一个如下列表
[Child A (2), Child B (3), Child A (4)]
这是我最好的尝试:
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));