【发布时间】:2016-02-05 02:04:13
【问题描述】:
我尝试了不同的类型并阅读了文档,但我无法确定过滤属性内幕 Ref 是可能的。
这是我的课程: 我的啤酒.class
@Entity
public class Beer {
@Id
private Long keyBeer;
@Load
@Index
Ref<BeerBrand> beerBrandRef;
}
这就是 Item.class
@Entity
public class Item {
@Index
@Load
Ref<Beer> beerRef;
..Fields
}
我正在尝试按beerBrandRef 过滤项目。例如,对于特定品牌,我需要列出所有具有 beerBrandRef 的商品。
这是我的端点代码:
首先我从我拥有的 Key 中加载 beerBrandRef:
BeerBrand tmpBrand = ofy().load().type(BeerBrand.class)
.id(pBrandKey).now();
然后我尝试在过滤器中传递 Ref:
items = ofy().load().type(Item.class)
.filter("beerRef.beerBrandRef", tmpBrand)
.list();
有可能吗?如果没有,我如何构建我的数据存储以使这种搜索工作(不一定使用 Ref)
Ps:这是我第一个使用 GAE、Datastore 和 Objectify 的项目,所以我有点迷茫。
感谢您的帮助。
【问题讨论】:
标签: java google-app-engine google-cloud-datastore objectify