Getting a model by Key

To retrieve a model given its key, use Datastore.get() method. The method takes the model class and key:
Key key = ...;
Employee emp = Datastore.get(Employee.class, key);

To retrieve multiple models given its keys, use Datastore.get() method. The method takes the model class and keys. This method is more efficient than a series of individual Datastore.get() invocations.
List<Key> keys = ...;
List<Employee> list = Datastore.get(Employee.class, keys);

List<Employee> list = Datastore.get(Employee.class, key, key2, key3);

You can retrieve multiple models asynchronously as follows:
List<Key> keys = ...
Future<List<Employee>> future = Datastore.getAsync(Employee.class, keys);
// Do something
...
// Get the result
List<Employee> list = future.get();

Next...

Continue to Updating a model.


Comments