You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by Bob Schellink <sa...@gmail.com> on 2009/07/05 18:38:58 UTC

GAE: Click JPA demo

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

Re: GAE: Click JPA demo

Posted by "Adrian A." <a....@gmail.com>.
> 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/
Very nice, thank you :).


> To access the EntityManager I've opted for a EntityManager per request 
> pattern
> by specifying a filter which binds the EntityManager to a ThreadLocal.
IMHO the EntityManagerFilter(+utils) would be better in Click-Extras, in 
package, e.g.
org.apache.click.extras.gae.*
for a faster reuse by the users.

Thank you,

Adrian.