On Fri, Sep 18, 2009 at 1:53 PM, C N Davies <[email protected]> wrote:
> Sure I added some debug code, I'll run a unit test and come back to you > when > it fails with this specific SingleFieldManager exception. > > While following a hunch that my problem was related to multi-threading, I accidently managed to reproduce my original stack trace exactly, including the PK of the FailedObject! The problem isn't with multi-threading per se, but "multi em". It seems this error is thrown when the referenced object is currently managed by a *different* em. This should illustrate: EntityManagerFactory factory = getEntityManagerFactory(); EntityManager em1 = factory.createEntityManager(); B b = em1.find(B, 1); //em.close(); EntityManager em2 = factory.createEntityManager(); em2.getTransaction().begin(); A a = new A(); a.setB(b); em2.persist(a); em2.getTransaction().commit(); Uncomment em.close() and it works. So now to figure out if this is the source of my problem - it's possible some freak condition causes my initial em to stay open. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
