On Wed, Jul 1, 2009 at 10:03 AM, Daryl Stultz (via Nabble) < [email protected]<ml-user%[email protected]> > wrote:
> To be a little more clear, entity.save() looks like this: > > EntityManager em = getEntityManager(); > boolean alreadyInTransaction = em.getTransaction().isActive(); if (! alreadyInTransaction) em.getTransaction().begin(); if (getId() == null) em.persist(this); else em.merge(this); > if (! alreadyInTransaction) em.getTransaction().commit(); I have to admit to only cursorily (is that a word?) scanning this, but remember that merge() has a return value, and the return value supersedes the value you passed into it. You need to follow this pattern when merging: final X newThing = em.merge(oldThing); ...and then "throw out" oldThing, since it is effectively no longer valid. Given that you are merge()ing "this", that might be difficult. :-D I hope that helps at least somewhat. Good luck. Best, Laird -- View this message in context: http://n2.nabble.com/State-Management%2C-changed-properties-on-detached-object-not-saving-tp3188832p3189415.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
