这里描述了如何通过无主的一对一关系过滤实体:
Food chocolate = /*...*/;
Query q = pm.newQuery(Person.class);
q.setFilter("favoriteFood == favoriteFoodParam");
q.declareParameters(Key.class.getName() + " favoriteFoodParam");
List<Person> chocolateLovers = (List<Person>) q.execute(chocolate.getKey());
这工作得很好,但是如果我有多个 favouriteFoodParam 怎么办?
我尝试将过滤器修改为:
q.setFilter("favoriteFood == favoriteFoodParam1 || favoriteFood == favoriteFoodParam2");
q.declareParameters(Key.class.getName() + " favoriteFoodParam1,"+Key.class.getName() + " favoriteFoodParam2");
但是执行 return 0 个对象,如果我删除了 favoriteFoodParam1 或 favoriteFoodParam2 然后返回不是 0。