java - 使用集合查询

标签 java google-app-engine objectify

我有一个需要查询的实体:

@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/

相关文章:

Javascript:如何从网络应用程序使用 Google API 访问*特定用户*数据?

java - 通过缓存加速重复操作

java - 在 AppEngine 标准环境中使用 java 创建线程

java - 清除并构建时更改 lib 文件夹

java - 如何使用 FTP 知道服务器上的文件是否完整?

java - 可以在父类(super class)中声明一个返回子类类型对象的方法吗?

安卓工作室 : how to setup generated Cloud Endpoints sources?

google-app-engine - 如何在 objectify 中通过嵌套 Refs 进行查询

java - 事务中的祖先查询(objectify)返回数据 "frozen in time"

java - IBM WebSphere 8.5.5.8(Liberty) + Spring Security 3.1.3.RELEASE