openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <>
Subject Re: EntityManager used in multiple threads
Date Fri, 18 Sep 2009 13:51:45 GMT
On Fri, Sep 18, 2009 at 9:40 AM, C N Davies <> 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.


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.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message