On Mon, Apr 5, 2010 at 4:05 PM, Rick Curtis <[email protected]> wrote:

> Daryl I'm not entirely sure I follow your last email. My understanding of
> the problem is that we are trying to merge a detached entity that has a
> relationship to an entity which is in a different persistence context.


I don't think I have a good enough understanding of JPA to explain what I
mean. Maybe something like this:

em = getEmFromFactory();
EntityB b = getBFromQuery(em);
EntityA a = new EntityA();
a.setB(b);
Thread.sleep(1000);
em.persist(a);

If two threads enter this code overlapping by a few millis, could "b" fail
due to it being managed by the other thread's em? I figure if the problem
with my code resulted in an em being left open and this error being thrown,
then there might be a race condition present even after fixing the problem
in my code, just with a smaller window.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]

Reply via email to