【发布时间】:2016-08-17 14:18:19
【问题描述】:
在我的 Spring 项目中并使用 Google App Engine,我试图从数据存储区获取一个实体,但在这种情况下,这个实体有一个 @Parent 关系。我只有实体的 id,这一点不知道有关 Parent 关系的信息。
我尝试了不同的查询,使用ancestorfilterKey,此时我有这个:
@Override
public House getNotRestrictions(Long id){
return objectifyService.ofy().load().type(House.class).filterKey(Key.create(House.class, id)).first().now();
}
我的模型是这样的:
@Entity
public class House {
@Id
public Long id;
//other attributes
@Index
@Parent
public Key<User> createdBy;
//methods getter and setters
}
当我执行查询时,它返回给我和空实体。但数据存储区的 id 存在。
【问题讨论】:
-
以下答案可以帮助您:stackoverflow.com/questions/37813998/…
标签: java google-app-engine objectify google-cloud-datastore