我有一个需要查询的实体:
@Entity
public class Resource implements Serializable {
@Id
private Long id;
private List<String> key;
}
这是查询:
List<String> keyPath = key.getFullPath();
Resource result = ofy().load().type(Resource.class).filter("key =", keyPath).first().get();
我收到此错误:
java.lang.IllegalArgumentException: A collection of values is not allowed.
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:140)
at com.google.appengine.api.datastore.Query$FilterPredicate.<init>(Query.java:867)
问题:
- 是否可以使用 List 等集合作为查询值进行查询?
- 是否可以使用 Objectify 查询或 native 数据存储区查询?
- 如果没有,执行此类查询的方法是什么
这个想法是查询获取具有与查询值相同的字符串列表(key
字段)的 Resource
实体。
最佳答案
您是否尝试过使用 IN
运算符?
Resource result = ofy().load().type(Resource.class).filter("key IN ", keyPath).first().get();
关于java - 使用集合查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12871077/