How does it relate to the new "record" way of accessing database?
On Dec 14, 6:19 am, "Derek Chen-Becker" <[email protected]> wrote: > OK, party people. I've broken out behaviors into a number of traits. Since > I'm coming at this from Lift, I've also added a nice trait to make using JPA > from Lift nice and simple. For now I'll host the scaladocs up on my own > website: > > http://chen-becker.org/scalajpa/scaladocs/index.html > > The code is available on git: > > http://github.com/dchenbecker/scalajpa/tree/master > > Just to give you a sample of what this can do, here's how we define a Local > JPA module: > > object Model extends LocalEM("mypersistenceunit") with RequestVarEM > > Ta da! That's it; oyu no longer have to code up the request var stuff, or > even transaction handling (it's optional on the LocalEM trait, but JNDI > generally requires JTA). If you want JNDI instead: > > object Model extends JndiEM("java:/MyUnitEM") with RequestVarEM > > If you'd rather manage the EMs yourself, just drop the RequestVarEM: > > object Model extends LocalEM("foo") > > and in your code: > > val em = Model.newEM > em.findAll(...) > em.close() > > The RequestVarEM (and ThreadLocalEM, for use outside of Lift) can be used to > make your object a singleton ScalaEntityManager, so the EM methods are > called directly on your object: > > Model.createNamedQuery(...) > Model.lock(...) > > I think that with this design we get maximum flexibility by using the traits > to control independent behaviors, but as always I'm open to suggestions. One > thing I've been vacillating on is naming things like RequestVarEM > RequestVarSingleton to explicitly show that it makes the object a singleton > EM, but I don't know that it makes a huge difference either way. > > Cheers, > > Derek > > PS - I'll discuss getting this up on scala-tools.org with David B. so that > it's in the repos soon. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
