![](/img/trans.png)
[英]How to correctly retrieve int from a Google App Engine datastore (Java)?
[英]Google app engine(java) datastore retrieve not working
我无法从数据存储中检索实体。
以下: Google Code Lab我实现了此功能:
@SuppressWarnings("deprecation")
public static Iterable<Entity> listEntities(String kind, String searchBy,String searchFor) {
com.google.appengine.api.datastore.DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Query q = new Query(kind);
if (searchFor != null && !"".equals(searchFor))
{
q.addFilter(searchBy, FilterOperator.EQUAL, searchFor);
}
PreparedQuery pq = ds.prepare(q);
return pq.asIterable();
}
然后调用它来获取值:
for(Entity u:listEntities("Upload","UID","ratan"))
{
String uid = (String) u.getProperty("url");
System.out.println("#1##"+uid);
}
但是它不会输出任何值! 我哪里出错了。
这是我的“上传”实体的数据存储区实例
即使这样也不起作用:
for(Entity u:listEntities("Upload",null,null))
{
String uid = (String) u.getProperty("url");
System.out.println("#1##"+uid);
}
您必须为此实体定义索引。 如何在App Engine中定义索引,请查看以下链接:
https://developers.google.com/appengine/docs/java/config/indexconfig
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.