Hi,There should not be any need to set the Multithreaded flag to correctly use exactly one entity manager for a thread. The entity manager factory itself is thread safe.
The usual symptom for a multithreading problem is an exception thrown inside an implementation method that can't be explained by application code.
What are your symptoms? Regards, Craig On Aug 3, 2009, at 6:43 AM, Claudio Di Vita wrote:
Jean-Baptiste BRIAUD -- Novlog wrote:Did you compared using == what you think is different instance of EntityManager ? Reading your message tend to prove that EntityManager is shared and when you think you got a new one it is not a new one.Why I have to check an instance returned by a threadlocal variable ?? I use the following Th ThreadLocal<EntityManager>: private static class ThreadLocalEntityManager extends ThreadLocal<EntityManager> { /* (non-Javadoc) * @see java.lang.ThreadLocal#get() */ @Override public EntityManager get() { /* Get the current entity manager */ EntityManager em = super.get(); /* The entity manager was closed */ if (!em.isOpen()) { /* Create a new entity manager */ em = factory.createEntityManager(); /* Update the entity manager */ set(em); } return em; } /* (non-Javadoc) * @see java.lang.ThreadLocal#initialValue() */ @Override protected EntityManager initialValue() { return factory.createEntityManager(); } } Where factory is a static EntityManagerFactory. What is going wrong ?? -----Not everything that can be counted counts, and not everything that counts canbe counted - Albert Einstein -- View this message in context: http://n2.nabble.com/Persist-issue-in-multithreaded-environment-tp3377510p3377741.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Craig L Russell Architect, Sun Java Enterprise System http://db.apache.org/jdo 408 276-5638 mailto:[email protected] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
