Objectify is a Java data access API specifically designed for the Google App Engine datastore. Its goals are to:
Objectify provides a level of abstraction that is high enough to be convenient, but low enough not to obscure the key/value nature of the datastore. It is intended to be a Goldilocks API - not too low level, not too high level, just right.
If you are new to Google App Engine, start with Concepts
This is a quick tour of what using Objectify looks like, intended to give you a taste of the framework. Full explanations can be found later in the documentation.
A simple entity:
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Index; @Entity public class Car { @Id Long id; @Index String license; int color; }
Somewhat more complicated:
import com.googlecode.objectify.annotation.AlsoLoad; import com.googlecode.objectify.annotation.Cache; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.IgnoreSave; import com.googlecode.objectify.annotation.Load; import com.googlecode.objectify.annotation.OnLoad; @Entity @Cache public class Motorcycle { @Id String vin; @Load List<Ref<Person>> owners = new ArrayList<Ref<Person>>(); @AlsoLoad("colour") int color; @IgnoreSave boolean ktm; @OnLoad public void onLoad() { if (ktm) color = ORANGE; } }
import static com.googlecode.objectify.ObjectifyService.ofy; Car porsche = new Car("2FAST", RED); ofy().save().entity(porsche).now(); // async without the now() assert porsche.id != null; // id was autogenerated // Get it back Result<Car> result = ofy().load().key(Key.create(Car.class, porsche.id)); // Result is async Car fetched1 = result.now(); // Materialize the async value // More likely this is what you will type Car fetched2 = ofy().load().type(Car.class).id(porsche.id).now(); // Or you can issue a query Car fetched3 = ofy().load().type(Car.class).filter("license", "2FAST").first().now(); // Change some data and write it porsche.color = BLUE; ofy().save().entity(porsche).now(); // async without the now() // Delete it ofy().delete().entity(porsche).now(); // async without the now()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4