Cloud Zone is brought to you in partnership with:

Mitch Pronschinske is a Senior Content Analyst at DZone. That means he writes and searches for the finest developer content in the land so that you don't have to. He often eats peanut butter and bananas, likes to make his own ringtones, enjoys card and board games, and is married to an underwear model. Mitch is a DZone Zone Leader and has posted 2574 posts at DZone. You can read more from them at their website. View Full User Profile

Spring + Hibernate + Google AppEngine's Cloud SQL = Awesome!

11.04.2011
| 18160 views |
  • submit to reddit
Java developers like Keith Mukai are doing some pretty awesome things with Google's preview of Cloud SQL for Google AppEngine.  Keith created a proof-of-concept app using Spring and Hibernate that was approved by Google to be part of the Cloud SQL limited preview which began last month.

Keith decided to use Hibernate because of his familiarity with using its annotations for his ORM layer.  After being out of the Hibernate world for so long, it felt like being in 2003 again, because he had to use Hibernate Tools and reveng.xml to generate the Hibernate *.hbm.xml mapping files.  He had to do this because annotations wouldn't work in AppEngine due to their limitations which don't support the JPA 2.0 spec.  Maybe there's a way around this, but Keith couldn't find it, so it was a little bit tedious.  However, the end result was worth it:

Once the basics were working I retrofitted my Java generics-based approach to the DAO layer that I had built for the App Engine datastore with Objectify. It gets a little complicated, but basically there's only ONE class that's actually implementing all the standard DAO CRUD. Java generics do the rest to apply that code to each domain entity. It's pretty damn cool.  --Keith Mukai

Keith also decided that Hibernate would work better through Spring for his app, so maybe the frequent Spring users out there can find some interesting code in Keith's app.

Download the project code here. And let Keith know if there are any issues with the code.  He doesn't claim to be a Java expert.

The approach he used is discussed in more detail here:
http://blog.essaytagger.com/2011/07/elegant-coding-with-objectify-java.html

The question now is, have all the recent changes to Google's AppEngine offerings alienated developers?  And is Cloud SQL a lucretive addition that will continue to bring in developer interest?

Source: http://blog.essaytagger.com/2011/11/spring-hibernate-on-google-app-engines.html