How do i get all child entities in Google App Engine (Low-level API)

青春壹個敷衍的年華 提交于 2019-12-23 12:57:55

问题


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));

回答1:


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




回答2:


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

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



来源:https://stackoverflow.com/questions/998794/how-do-i-get-all-child-entities-in-google-app-engine-low-level-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!