简体   繁体   English

使用过滤器进行对象化投影查询

[英]Objectify Projection Query with Filters

Given the class 给定班级

@Entity
public class Goat{
   Long pen;
   Long car;
   Boolean active;
   …
}

I need to create a projection query that returns a list of Long s. 我需要创建一个投影查询,该查询返回Long的列表。 How should I edit the following so it works? 我应如何编辑以下内容使其起作用?

List<Long> cars = ofy().load().type(Goat.class).filter("pen", pen).filter("active", true).project("car").list();

You need to index all fields you plan to query/filter on. 您需要索引计划查询/过滤的所有字段。 eg. 例如。

@Index
 Long pen;
@Index
 Long car;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM