On Mon, Jan 4, 2010 at 2:19 PM, Pinaki Poddar <[email protected]> wrote:

>
> Hi,
>  Possibly the following causing the trouble:
>   The instances are crossing serialization boundary and once they are
> coming back to OpenJPA managed runtime, OpenJPA not seeing any marker on
> them -- and thereby identifying them as purely new instead of detached
> instances.


I considered that some time ago. I'm using a web application framework
called Zk which is AJAX-enabled. The "page state" is cached on the server. I
don't believe the state is ever serialized. I couldn't get any feedback from
the developers on the issue.

I certainly am not doing anything to serialize the entities.

I should also note that I can reproduce the stack trace with this code:

EntityManagerFactory factory = getEntityManagerFactory();
EntityManager em1 = factory.createEntityManager();
B b = em1.find(B, 1);
//em.close(); // uncomment and it works
EntityManager em2 = factory.createEntityManager();
em2.getTransaction().begin();
A a = new A();
a.setB(b);
em2.persist(a);
em2.getTransaction().commit();

I posted this on 9/21/09. The above has "b" managed by em1 when em2 commits.
The error is misleading as "b" is in fact managed but by a different em. I
am managing my EMs on a ThreadLocal. I did discover a bug in ThreadLocal
that provides a plausible scenario for the first em in the thread getting
lost (and left open) but I've upgraded to JDK 1.6 which does not have the
bug. I have had the exception occur on JDK 1.6 so while a real bug has been
closed I'm not sure it's the cause of my problems in general. It's all
rather inconclusive.

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

Reply via email to