Clone wiki

gaeds / Home


gaeds ir small Google AppEngine for Java DatastoreService wrapper. Something like Object/Entity (keeping Object/Relational analogy) Mapping tool. Configuration is done using few focused annotations. It's fast and easy to use.


Declare model object (primitive types are not supported):

public class Person {

  private Key key;

  private String email;

  @Property(name = "firstName")
  private String name;

  private Long age; // Datastore anyway keeps all ints, shorts as longs

  private Key parent;

  // getters and setters


Let gaeds know about this model:

// guice is not required but assumed
public List<Class<?>> provideModelClasses() {
  List<Class<?>> classes = new ArrayList<Class<?>>();


  return classes;

Create session factory:

private SessionFactory sf;

Get session and get, put, query models:

Session sess = sf.startSession();

// count (max 1000)
int count = sess.count(Person.class)

// put (also batch put is supported)
Person person = sess.put(new Person(...));

// get by key (also batch get is supported)
Person person = sess.get(key);

// delete by model or key (also batch delete is supported)

// Query

// query all (asList, singleResult, asIterable, asIterator are supported)
List<Person> list = sess.query().model(Person.class).asList();

// query for single result
Person person = sess.query().model(Person.class).singleResult();

// query by ancestor and model (kind)
List<Person> people = sess.query().ancestor(root, Person.class).asList();

// with limit, offset
List<Person> list = sess.query().model(Person.class).limit(1).offset(1).asList();

// keys only
List<Person> list = sess.query().model(Person.class).keysOnly().asList();

// filters (eq, gt, ge, lt, le are supported)
List<Person> list = sess.query().model(Person.class).eq("firstName", "ampatspell").asList();

// sorting (asc, desc)
List<Person> list = sess.query().model(Person.class).asc("age").asList();


sess.transaction(new TransactionCallback<Void>() {
  public Void execute(Session sess) {
    // in transaction
    return null;

Direct access to Entity:

Person person = sess.model(Person.class); // returns proxy what implements Model
person.setEmail(""); // part of the Key. must be set prior accessing Entity

Model m = (Model) person;
m.getEntity().setProperty("additional", "something");


// --

Person person = sess.get(someKey); // returns proxy what implements Model
Model m = (Model) person;

String additional = m.getEntity().getProperty("additional");
m.getEntity().setProperty("oneMore", "propertyValue");


Information about differences between Model declared properties and actual current Entity properties:

Person person = sess.get(key); // returns proxy what implements Model

Model m = (Model) person;
// returns property names which could not be casted to model types 
// (before concurrent datastore migration has completed)
List<String> incompatible = m.getIncompatibleProperties();

// returns property names which are not available in given Entity.
// (if Entity property is just null, it's not listed here)
List<String> missing = m.getMissingProperties();

Additional information