openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <da...@6degrees.com>
Subject Re: Unmanaged Object Problems
Date Mon, 05 Apr 2010 20:28:15 GMT
On Mon, Apr 5, 2010 at 4:05 PM, Rick Curtis <curtisr7@gmail.com> 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:daryl@6degrees.com

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