Howdy Guys,
I've been asking this question for some time now (StackOverflow,
EclipseLink, JavaRanch) - without any luck.
If I correctly understand the JPA 2.0 specification, it's the container
(Glassfish) responsible for processing the persistence.xml, discovering
the JPA Provider and creating an EntityManagerFactory. If so, than it's
*the container responsibility* to manage the EntityManagers? In the
specification, there is the following part:
"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."
As I understand it, it allows the container (or the jpa-provider?) to
either create new EntityManager each time or reuse it's instances
(perhaps using a proxy?).
If so, than how is Glassfish managing the EntityManagers?
Is there a way I can check two EntityManager instances for equality?
Can I do naive System.out.println(em) and check the value for
PersistenceContexts equality?
Thanks in advance!
Regards,
Piotr