4

我在 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));
4

2 回答 2

3

我发现这是本地开发服务器中的一个已知错误。上传到谷歌时它工作正常

于 2009-06-17T14:27:16.783 回答
0

不会getKey()是方法,不是属性 ( ent.getKey(),不是ent.getKey?

还有,不parentKey一样pe.getKey()吗?

于 2009-06-15T22:47:34.493 回答