【问题标题】:How do i get all child entities in Google App Engine (Low-level API)如何在 Google App Engine 中获取所有子实体(低级 API)
【发布时间】:2009-06-15 22:37:19
【问题描述】:

我正在使用 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));

【问题讨论】:

    标签: java google-app-engine google-cloud-datastore


    【解决方案1】:

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

    【讨论】:

    • 这是一个已知的错误吗?错误跟踪器上有链接吗?
    • 您能找到解决此问题的错误吗?因为我也在 GAE 上开发一些东西,并且厌倦了每隔几秒运行一次更新!!!
    【解决方案2】:

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

    另外,parentKeype.getKey() 不一样吗?

    【讨论】:

    • 谢谢,我修正了错字。至于 pe.getKey(),我只有实际执行查询时的 Id 号,所以我想我会包括我是如何获得密钥的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多