如何获取Google App Engine中的所有子实体(低级API) [英] How do i get all child entities in Google App Engine (Low-level API)
本文介绍了如何获取Google App Engine中的所有子实体(低级API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Google App Engine for Java中使用低级API,并希望获得特定父实体的所有子实体:
鉴于以下图:
家长(1)
|
+ ---小孩A(2)
| |
| + ---孩子B(3)
|
+ --- Child A(4)
我想要一个像下面的
[Child A(2),Child B(3),Child A(4)]
$ c
$
$ b 这是我最好的尝试:
实体pe =新实体(父);
实体c1 =新实体(childA,pe.getKey());
实体c2 =新实体(childB,c1.getKey());
实体c3 =新实体(childA,pe.getKey());
//为了简洁省略了存储代码
关键parentKey = KeyFactory.createKey(null,parent,1);
//根据文档,这应该工作(但不)
PreparedQuery q = datastore.prepare(new Query(parentKey));
解决方案我发现这是一个已知的bug本地开发服务器。当上传到谷歌它工作正常
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));
解决方案 I found out that this is a known bug in the local development server. When uploading to google it works fine
这篇关于如何获取Google App Engine中的所有子实体(低级API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文