Hello!
I am using Hibernate 3.2.2.ga with hibernate 3.2.0.ga entitymanager and 3.2.0.ga annotations.
I am using a Java SE environment. This means, an extended context, application managed entity managers, and resource local transactions.
The documentation for application managed entity managers says: "When you create an entity manager inside a transaction, the entity manager automatically join the current transaction."
I have the following (pseudo) code:
Code:
//create entity manager factory
EntityManagerFactory emf = configuration.buildEntityManagerFactory...
//create the first (outer) entity manager
//this also creates our persistence context
EntityManager em_outer = emf.createEntityManager();
//start transaction
em_outer.getTransaction().begin();
//now we create a second entity manager
//the inner entity manager should join the current transaction
em_inner = emf.getEntityManager();
//make a merge with some object
em_inner.merge(object);
//now we close the transaction
em_outer.getTransaction().commit();
em_outer.close();
this doesn't work for me. I have tried a lot, but without success. Only the merge EventListeners are fired, but no records are merged.
Any ideas?
Regards,
Chr.