I think we are talking about the same thing, the think is that I never knew about JpaUtils so I had written my own! :) Bloody hell!
-----Original Message----- From: Daryl Stultz [mailto:[email protected]] Sent: Friday, 18 September 2009 9:52 PM To: [email protected] Subject: Re: EntityManager used in multiple threads On Fri, Sep 18, 2009 at 9:40 AM, C N Davies <[email protected]> wrote: > I was only commenting on the point you made regarding > > I think we're talking about different coding patterns. With a managed entity (in a long transaction or a case with only one em), you can call em.refresh(object), but this returns a new instance of the class. I'm talking about a way to push the values from a fresh instance into an existing one. So: final A a = em.find(A.class, 1); em.close(); // a is detached ... em = getEm(); A a1 = em.find(A.class, a.getId()); // a1 is managed and fresh JpaUtils.merge(a, a1); // copy from fresh to detached The merge method here would copy properties from a1 to a, thus preserving a's "final" modifier. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
