Objectify

For the last few weeks I was working on a Google App Engine application that should be a kind of hosted version of the LogDigger Server. I quickly gave up of using Grails framework (more on that on another occasion) and decided to use plain Java, although I was still undecided on which persistence API to use; JDO, JPA or Google’s low-level Datastore API.

During my research for the project, I’ve found this GAE Datastore Performance Test that shows that using JDO has a significant overhead, with some tests being more than 5 times slower than using the low-level API. It’s quite possible that Google will improve performance of JDO in the future but I really don’t see any advantage of using JDO over low-level API. Further reading of GAE mailing lists about JDO/JPA issues, furrther convinced me that the low-level API is the way to go.

(Some will say that JDO offers clear advantage of being portable but I don’t buy it. This application was planned specifically for GAE with no plans to port it to the “standard” J2EE. In addition, datastore design for Bigtables would be different than for a relation database so there’s no easy port anyway.)

Further research took me 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.” After using it for few days, I can say only… wow!

Objectify is so easy to use that you don’t even need to look at Google’s low-level API. Of course, it’s still highly recommended that you have understanding of the capabilities of the underlaying Bigtables so that you can properly design your datastore, but Objectify takes the burden of messing with the API and allows you to use your POJO classes. One of the features I really like is support for embedded classes.

So, if you work with GAE/J but didn’t have a chance to try Objectify before, I cannot recommend it enough. It might save you a ton of hours.

Comments