在 Objectify Google 数据存储中使用过滤器和投影时出错
Error using Filter and Projection in Objectify Google Datastore
我正在尝试使用 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 已编入索引。
我不知道 Objectify,但在 Google App Engine 数据存储中 Projection query limits the returned results to just the column(s) specified. Using distinct
is the same as grouping 并且从错误消息来看,您似乎需要将 rewardPoints
添加到投影中为了同时使用不等式过滤器和不同。
看来乔希是对的。我更改了查询,它运行良好。
Query<Coupon> coupons = ObjectifyService.ofy().load().type(Coupon.class).filter("rewardPoints !=", "").project("rewardPoints").project("code").distinct(true);
我正在尝试使用 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 已编入索引。
我不知道 Objectify,但在 Google App Engine 数据存储中 Projection query limits the returned results to just the column(s) specified. Using distinct
is the same as grouping 并且从错误消息来看,您似乎需要将 rewardPoints
添加到投影中为了同时使用不等式过滤器和不同。
看来乔希是对的。我更改了查询,它运行良好。
Query<Coupon> coupons = ObjectifyService.ofy().load().type(Coupon.class).filter("rewardPoints !=", "").project("rewardPoints").project("code").distinct(true);