我有一个 EntityKind SuggestedInterest。当我用键“GrpId”和属性“suggestedint”填充它时。
现在,我需要请求的“GrpId”的“suggestedint”值
因此,我将查询编写为:
String findSuggestedInterest(String grpId)
{
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Filter filter = new FilterPredicate(Entity.KEY_RESERVED_PROPERTY,FilterOperator.EQUAL,grpId);
Query q0 = new Query("SuggestedInterest").setFilter(filter);
PreparedQuery pq0 = datastore.prepare(q0);
Entity result = pq0.asSingleEntity();
return result.getProperty("suggestedint").toString();
}
当我执行此代码时,我得到
java.lang.IllegalArgumentException: __key__ filter value must be a Key
开发人员文档告诉使用 Entity.KEY_RESERVED_PROPERTY 来查询键,但我想我误解了。查询 key 的正确方法是什么?