|How can I check PersistenceContexts for equality [message #757045]
||Wed, 16 November 2011 03:50
| Piotr Nowicki
Registered: November 2011
Is there a way to check if two EntityManagers instances represents the same PersistenceContext (container-managed, transaction-scoped) in EclipseLink?
Here is a paragraph from the JPA 2.0 specification:
7.8.2 Container Managed Persistence Contexts
When operating with a third-party persistence provider, the container uses the contracts defined in section 7.9 to create and destroy container-managed persistence contexts. It is undefined whether a new entity manager instance is created for every persistence context, or whether entity manager instances are sometimes reused. Exactly how the container maintains the association between persistence context and JTA transaction is not defined.
If I understand it correctly, the JPA specification doesn't mandates if single EntityManager can be reused to represent multiple PersistenceContexts or each EntityManager instance will represents only one PersistenceContext and at the end it'll be released.
My question is - how it's in the EclipseLink. Does it reuse the EntityManager? Can I do naive 'System.out.println(em)' and check the EntityManager default toString() value for PersistenceContexts equality?
Or maybe it's not the EclipseLink responsibility to create/reuse the EntityManagers but the Application Server?
Thanks a lot for any clarifications.
This question has been also asked on StackOverflow and Javaranch - without any luck.
Powered by FUDForum
. Page generated in 0.07111 seconds