【发布时间】:2014-10-16 06:56:40
【问题描述】:
我有一个作为实体存储的 ObjectS 类。在这个 ObjectS 中,我通过以下方式将 ObjectP 声明为父级。
@Parent
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
private Key<ObjectP> objectPKey;
然后,我的 api 如下所示,
@ApiMethod(
name = "getObjectPChildren",
path = "getObjectPChildren",
httpMethod = HttpMethod.POST
)
public Collection<ObjectS> getObjectPChildren(@Named("websafeObjectPKey") final String websafeObjectPKey)
{
Key<ObjectP> objectPKey = Key.create(websafeObjectPKey);
Query<ObjectS> q = ofy().load().type(ObjectS.class)
.ancestor(objectPKey);
return q.list();
}
当我使用 websafeObjectPKey 创建实体 ObjectS(使用 API 资源管理器中的一些其他 API)时,我可以在本地数据存储中看到实体。但是,上面的查询返回空的意思是它说没有实体:-(。有趣的是,如果我将查询修改为以下
Query<ObjectS> q = ofy().load().type(ObjectS.class);
它确实返回了数据存储区中的所有实体!这意味着数据存储不知何故不知道祖先关系。我想知道我做错了什么?
【问题讨论】:
标签: java google-app-engine google-cloud-datastore objectify