Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将查询对象化为与中相反的_Java_Database_Google Cloud Datastore_Google Cloud Platform_Objectify - Fatal编程技术网

Java 将查询对象化为与中相反的

Java 将查询对象化为与中相反的,java,database,google-cloud-datastore,google-cloud-platform,objectify,Java,Database,Google Cloud Datastore,Google Cloud Platform,Objectify,假设我有一个名为EntityA的实体类型,我有一个EntityA ID列表。如何从数据库中查询该id不在我拥有的EntityA id列表中的所有EntityA实体 我试着做一些类似的事情: ofy().load().type(EntityA.class).filter("!IN", entityAKeys); 我怎样才能让它工作呢?可能吗?不,这不受支持,因为云数据存储只允许由索引支持的查询,以确保它们在扩展数据集时不会中断 您必须查询实物EntityA中的所有实体,并自己过滤掉客户端enti

假设我有一个名为EntityA的实体类型,我有一个EntityA ID列表。如何从数据库中查询该id不在我拥有的EntityA id列表中的所有EntityA实体

我试着做一些类似的事情:

ofy().load().type(EntityA.class).filter("!IN", entityAKeys);

我怎样才能让它工作呢?可能吗?

不,这不受支持,因为云数据存储只允许由索引支持的查询,以确保它们在扩展数据集时不会中断


您必须查询实物EntityA中的所有实体,并自己过滤掉客户端entityAKeys中的实体。

不支持,因为云数据存储只允许索引支持的查询,以确保它们在扩展数据集时不会中断


您必须查询实物EntityA中的所有实体,并自己过滤掉客户端entityAKeys中的实体。

因此我最后做了如下操作:

List<Key<MXChallenge>> keyList = new ArrayList<>();
List<Key<MXChallenge>> searchInKeys = ofy().load().type(MXChallenge.class).keys().list();

for(Long id : alreadyRetrieved){
    keyList.add(Key.create(MXChallenge.class, id));
}

searchInKeys.removeAll(keyList);

QueryResultIterator<MXChallenge> iteratorChallenges = ofy().load()
        .type(MXChallenge.class).filter("colour", "blue").filterKey("IN", searchInKeys).iterator();
List keyList=new ArrayList();
List searchInKeys=ofy().load().type(MXChallenge.class).keys().List();
用于(长id:alreadyRetrieved){
添加(Key.create(MXChallenge.class,id));
}
searchInKeys.removeAll(键列表);
QueryResulterator迭代器iteratorChallenges=ofy().load()
.type(MXChallenge.class).filter(“颜色”,“蓝色”).filterKey(“IN”,searchInKeys).迭代器();

虽然我对性能也不确定,但由于这是一个“仅按键”操作,我认为应该可以。因此,我最后做了如下操作:

List<Key<MXChallenge>> keyList = new ArrayList<>();
List<Key<MXChallenge>> searchInKeys = ofy().load().type(MXChallenge.class).keys().list();

for(Long id : alreadyRetrieved){
    keyList.add(Key.create(MXChallenge.class, id));
}

searchInKeys.removeAll(keyList);

QueryResultIterator<MXChallenge> iteratorChallenges = ofy().load()
        .type(MXChallenge.class).filter("colour", "blue").filterKey("IN", searchInKeys).iterator();
List keyList=new ArrayList();
List searchInKeys=ofy().load().type(MXChallenge.class).keys().List();
用于(长id:alreadyRetrieved){
添加(Key.create(MXChallenge.class,id));
}
searchInKeys.removeAll(键列表);
QueryResulterator迭代器iteratorChallenges=ofy().load()
.type(MXChallenge.class).filter(“颜色”,“蓝色”).filterKey(“IN”,searchInKeys).迭代器();

虽然我对性能也不确定,但由于它是一个“仅按键”操作,我认为应该可以。你能试试NIN是否工作吗?否则它完全“不在”“未知运算符”中。你能试试NIN是否工作吗?否则它完全“不在”“未知运算符”中。做
过滤键(“在”中)真的没有意义
-只需加载密钥本身。
ofy().load().keys(searchInKeys)
。这是因为在我的实际情况中,我有更多的过滤器。我会更新答案让它清楚。执行
过滤器密钥(“in”
-只需加载密钥本身。
ofy().load().keys(searinkeys)
。这是因为在我的真实案例中,我有更多的过滤器。我会更新答案,让它清楚。