Objectify 4过滤器无法正常工作

xyb*_*rek 4 java google-app-engine objectify

我正在尝试做一个简单的JUnit测试来执行这样的查询:

Resource result = ofy().load().type(Resource.class).filter("raw =", 
    "/Bob/-/userId/-/").first().get(); 
if (result != null){
    System.out.println("Resulting Resource raw =" + result.getRaw());
} 
Run Code Online (Sandbox Code Playgroud)

上面的查询结果null,但是当我使用id(Long类型)进行查询时,我得到了结果.当我坚持我正在尝试查询的实体时,我记录了@Id并且值是1,所以我做了一个查询id用于检查:

Resource result = 
    ofy().load().type(Resource.class).filter("id =", 1).first().get(); 
if (result != null){
    System.out.println("Resulting Resource raw =" + result.getRaw());
}
Run Code Online (Sandbox Code Playgroud)

结果result.getRaw()/Bob/-/userId/-/真的很奇怪,从我的第一次查询结果应该没有null

Vin*_*ini 10

检查你是否在该字段上有@Index,如果你试图通过没有索引的字段进行选择,即使它存在,你也会得到null.在几个领域,你当然需要索引所有这些领域.

*多个字段的索引将放在datastore-indexes.xml中https://cloud.google.com/appengine/docs/java/config/indexconfig