click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Schellink <sab...@gmail.com>
Subject GAE: Click JPA demo
Date Sun, 05 Jul 2009 16:38:58 GMT
Here is a small demo running Click+JPA on GAE:

http://click-jpa.appspot.com

The source can be found here:

http://code.google.com/p/click-jpa-demo/

To access the EntityManager I've opted for a EntityManager per request pattern
by specifying a filter which binds the EntityManager to a ThreadLocal.

As to be expected there are a number of restrictions enforced by GAE. Be sure
to read the following docs:

http://code.google.com/appengine/docs/java/datastore/
http://code.google.com/appengine/docs/java/datastore/transactions.html
http://code.google.com/appengine/docs/java/datastore/usingjpa.html

They have a weird notion called Entity Groups which basically amounts to an
object graph. However one cannot operate on more than one root entity per transaction.

Thus one cannot do:

   EntityManager em = ...
   for(Customer customer : customer) {
     em.persist(customer);
   }

GAE realizes that the above code snippet persists multiple root entities (Customers)
and throws an exception.

Instead one will have to start a new transaction for each root Entity.

Also from what I can gather it seems JDO is recommended instead of JPA. Probably
because there is no RDBMS backing the API.

All in all GAE seems interesting, but its definitely worth reading the docs and
get to grips with the limitations.

bob

Mime
View raw message