Trying to figure out some possible situations, when a EntityManagerFactory
could be useful in EJB. Of course usually one needs just an transaction-scoped EntityManager
(JTA scoped), so that all injected EntityManagers share the same PersistenceContext
.
What happens in the following situations:
When
@PersistenceContext(type=PersistenceContextType.EXTENDED)
is used: is this JTA-enabled? will the requests of such an EntityManager be executed in the context of the JTA? If not, that in which one? (Note: of course it works only with@Stateful
EJBs). Of course it is clear, that in this case the EntityManager will have its own/special PersistenceContext.When one uses
@PersistenceUnit
to get aEntityManagerFactory
in an EJB (I suppose it works in all type of EJBs, correct?), is the obtainedEntitymanager
JTA-enabled (of courseEntitymanager.joinTransaction()
is necessary)? How can one get a transaction-scoped (JTA enabled) or Extended EntityManager from the Factory? When would be useful to use the Factory, instead of a Entitymanager. (Of course it is clear that an EntityManagerFactory is the only interface for a Java SE application to the JPA, but what about EJB?).
@PersistenceContext
annotation. Again: I just was trying to figure some things out... – Andrei I