我正在尝试使用Objectify 5.1.8执行以下查询: -
Query<Coupon> coupons = ObjectifyService.ofy().load().type(Coupon.class).filter("rewardPoints !=", "").project("code").distinct(true);
for (Coupon coupon : coupons) {
out.write(coupon.getCode());
}
它给了我一个错误:
java.lang.IllegalArgumentException: Inequality filter on rewardPoints must also be a group by property when group by properties are set.
基本上,我希望实现的是在实体上执行过滤器和项目查询以及不同的查询。
如果查询有问题,请告诉我。
注意:rewardPoints已编入索引。
答案 0 :(得分:2)
我不了解Objectify,但在Google App Engine数据存储区中,Projection query将返回的结果限制为指定的列。使用distinct
与grouping相同,并且从错误消息中看起来您需要将rewardPoints
添加到投影中,以便同时使用不等式过滤器并使其不同。
答案 1 :(得分:1)
看起来Josh是对的。我改变了查询,它运作得很好。
Query<Coupon> coupons = ObjectifyService.ofy().load().type(Coupon.class).filter("rewardPoints !=", "").project("rewardPoints").project("code").distinct(true);