Katedral Pillon Katedral Pillon - 4 months ago 38
Java Question

get all entities using DatastoreService

Is there a way to get all entities using DatastoreService on AppEngine in Java? Basically if I do

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

What should I do next to get all the entities of a kind?


Run a query with no filters:

Query q = new Query("person");
for (Entity entity : datastore.prepare(q).asIterable()) {
    // do something with this entity

Note that if you have more than a 1,000 entities, it's better to read them in chunks. And if you have a very large number of entities, you may need to use a cursor. All of this is explained in the documentation.