Hello,
Quick question: Is the EntityManager thread safe?
For example,
class Foo {
private EntityManagerFactory emf =
Persistence.createEntityManagerFactory("my-persistence-unit");
private EntityManager manager = emf.createEntityManager();
// method accessed by several concurrent threads
public void foo() {
try {
manager.getTransaction().begin();
// TODO: do somethinf
manager.getTransaction().commit();
} catch(Exception e) {
manager.getTransaction().rollback();
}
}
}
thanks,
Daniel.