If you're using container managed persistence, and you look up a persistence unit by its JNDI name (as defined in ejb-jar.xml in the persistence-context-ref):
(i.e. EntityManager manager = (EntityManager) context.lookup(jndiName);
)
Is it an EMF associated with the PU behind the scene pumping out EMs, or is it just a global EM linked to a single thread?
I ask because I want to decouple persistence unit management from my DAOs, and this would be possible if it's a new EM each time, but if it's the same one, and EMs are not thread-safe, then I can't share it between 30 services.
Debugging shows it is an JpaTxEntityManager being returned, which I see is some sort of proxy object, but I can't find anywhere about how the mechanism is actually handled behind the scenes.
Does anyone know? Thanks