Skip to main content

JPA in the Clouds

Posted by jjviana on March 16, 2010 at 10:01 AM PDT

A big part of  my current company work is related to managing infrastructure hosted in cloud computing environments. I have recently released an open source project (Rain Toolkit) to help ease the management of Amazon EC2 objects. It is a set of command-line tools for performing day-to-day administration tasks.

Since Rain Toolkit deals with the management of EC2 resources, it seemed only natural that it should store its data on Amazon SimpleDB. SimpleDB offers a rest-based API that I planned to use, but then I came accross simplejpa.

Simplejpa is a JPA implementation on top of Amazon SimpleDB. It allows you to leverage your existing JPA experience and code when developing against SimpleDB. It support many JPA features such as @ManyToOne, @OneToMany, lazy loading , @Lob, etc.

It was a simple matter to integrate simplejpa into Rain Toolkit and it certainly saved me a lot of time in coding the SimpleDB access layer.

What is interesting is that Google AppEngine, the other leading cloud infrastructure platform, also supports Simple JPA for storage (see http://code.google.com/appengine/docs/java/datastore/usingjpa.html). I have used AppEngine in other projects and its JPA layer works most of the time just as a J2EE developer would expect.

Like Amazon SimpleDB, AppEngine storage (based on Google's BigTable) is a non-relational data storage system. JPA is flexible enough to provide an abstraction later for the leading cloud storage solutions even tough at the bottom they are both very different from the traditional relational databases.

Having said that, there are a few caveats a developer should be careful when using JPA against SimpleDB or AppEngine:

  • Join queries are not supported
  • Unowned relationships are not supported
  • Transactions are not supported in SimpleDB and have some limitations on AppEngine

Although these limitations may make porting of existing applications a challenge,  a J2EE developer should be able to feel comfortable using JPA in either of these cloud solutions when developing applications from scratch.

 

 

Comments

the rain toolkit is

the rain toolkit is definitely one of the best things that I learned how to use!