Katedral Pillon Katedral Pillon - 2 months ago 26
Java Question

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. 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();

Answer

You need to index all fields you plan to query/filter on. eg.

@Index
 Long pen;
@Index
 Long car;
Comments