Katedral Pillon Katedral Pillon - 1 year ago 101
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download