Hi, Comments inline
On Thu, Nov 12, 2009 at 11:44 AM, Cil-Gamir <[email protected]>wrote: > > Hi Daryl > > I'm not closing the entity manager, where should I do this ? > Well, when you're done using it.. From a quick look at your code you cache the EntityManager in your DAO, but never call the setEntityManager method. So you get a new instance of the EM each time you call getEntityManager(). I'd suggest updating your main test to cache the em. Something like this : . . . EntityManager em = getEntityManager(); em.getTransaction().begin(); em.persist(o); log.info("############# CREATE START"); em.commit(); em.close(); . . . em = getEntityManager() . . . I'd avoid caching it in the DAO for the time being.. > I'm also not familiar with enhancing, my entity classes were declared as > final, and JPA complained saying that it cannot do the enhancement for me > if > my classes are final. > <brief aside> That's a limitation of the subclassing approach to enhancement. If you run the stand-alone PCEnhancer tool you don't have to worry about final classes (AFAIK). </brief aside> > If I want to do the build time enhancement, where is a good place to start > to figure out how. > > Here's a good place to start : http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html > The basic scenario is as follows. > > 1. I fetch an entity > 2. I make a change to that entity and I save it (saving here involves > creating a new entity as i'm trying to version rows in the database). > 3. I fetch another different entity > 4. upon trying to save that entity it fails. > > If I only save without persisting a new entity I can do that the whole day. > but once I create a new entity the subsequent operation on any other entity > or the newly saved one throws an optimistic locking exception > -- > View this message in context: > http://n2.nabble.com/Re-SOLVED-Re-Locking-Exception-after-Persisting-new-entity-tp3992651p3994474.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >
