RSS Feed for This PostCurrent Article

AppEngine Objectify

The Google App Engine/J low-level datastore API is simple and elegant, neatly reducing your data operations to four simple methods: get, put,delete, and query. However, it is not designed to be used by the average developer:

  • DatastoreService persists GAE-specific Entity objects rather than normal POJO classes.
  • DatastoreService Keys are untyped and error-prone.
  • DatastoreService has a machine-friendly but not human-friendly query interface.
  • DatastoreService has an unnecessarily complicated transaction API.

Objectify-Appengine provides the thinnest convenient layer which addresses these issues, yet preserves the elegance of get, put, delete, andquery. In short:

  • Objectify lets you persist, retrieve, delete, and query your own typed objects.
  • Objectify surfaces all native datastore features, including batch operations, queries, entity groups, asynchronous operations, and partial indexes.
  • Objectify provides type-safe key and query classes using Java generics.
  • Objectify provides a human-friendly query interface based on GAE/Python’s Query class.
  • Objectify minimally impacts application cold-start time, typically adding only a few hundred milliseconds.
  • Objectify can automatically cache your data in memcache for improved read performance.
  • Objectify can store polymorphic entities and perform true polymorphic queries.
  • Objectify provides a simple, easy-to-understand transaction model.
  • Objectify provides built-in facilities to help migrate schema changes forward.
  • Objectify entities can be used in GWT without the need for Data Transfer Objects.
  • Objectify has no external jar dependencies beyond the GAE SDK. Just add objectify.jar to your project.
  • Objectify provides thorough documentation of concepts as well as use cases.
  • Objectify has an extensive test suite to prevent regressions.
   1: class Car {

   2:     @Id String vin; // Can be Long, long, or String

   3:     String color;

   4: }


   6: Objectify ofy = ObjectifyService.begin();

   7: ofy.put(new Car("123123", "red"));

   8: Car c = ofy.get(Car.class, "123123");

   9: ofy.delete(c);

Trackback URL

Sorry, comments for this entry are closed at this time.