在http://code.google.com/appengine/docs/python/datastore/entities.html#Saving_Getting_and_Deleting_Entities中,获取实体的批处理操作如下:
我找到了一个解决方案,可以在Datastore查询-查询接口示例中找到:
Query q = new Query("Person")
PreparedQuery pq = datastore.prepare(q);
for (Entity result : pq.asIterable()) {
String firstName = (String) result.getProperty("firstName");
String lastName = (String) result.getProperty("lastName");
Long height = (Long) result.getProperty("height");
System.out.println(lastName + " " + firstName + ", " + height.toString() + "inches tall");
}
我没有在查询中添加过滤器,因为它会从数据存储中返回所有实体。
entities = db.gql("WHERE StringKey >''").fetch(1000)