I am not sure why my following Objectify code is not working for searching within list of strings.

following is my entity class:

public class Employee
{
    @Id private Long id;
    .
    .
    private List <String> location;
    .
    .
    getter() .. setter()
}



Objectify ofy = ObjectifyService.begin();

List<Employee> employees= (List<Employee>) ofy.query(Employee.class).filter("location IN", "newyork");

employees list is empty .. even if i have Employee records with location arraylist containing "newyork"

有帮助吗?

解决方案

Try:

List<Employee> employees= (List<Employee>) ofy.query(Employee.class).filter("location", "newyork");

The IN operator in filter tells the query to search for Employees within a list of locations. Since you are only searching for one location, there is no need for this operator.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top