سؤال

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