The Pro EJB 3 book dictates on page 112 that the JPA defines no less than 3 different types of EntityManager. I can see only two of them, namely the Container Managed Entity Manager and the Application Managed Entity Manager. Which is the third one? Or is that simply a typo from the book?
There are two container-managed entity managers. The first one is transaction-scoped entity manager and the second one is extended entity manager. Both described on page 112 and on page 113. There is also application-managed entity manager described on page 117.
The extended and transaction scoped are subtypes for the Container Managed Entity Manager. But what about Application Managed Entity Manager. Can't they also be transaction scoped or extended scoped? Correct me if I'm wrong!
The extended and transaction scoped are subtypes for the Container Managed Entity Manager. But what about Application Managed Entity Manager. Can't they also be transaction scoped or extended scoped? Correct me if I'm wrong
1) Container Managed ::: Using Dependency Injection ...so the container is responsible for initializing the EntityManager @PersistenceContext
EntityManager entityManager;
2) Application Managed::: User or Application is Responsible for creating and initializing the EntityManager
Now coming back to Transaction or Extended ..those are the Persistence Context Types.
Container Managed Entity Manager can have any of the below Persistent Context Type
But what about Application Managed Entity Manager. Can't they also be transaction scoped or extended scoped? Correct me if I'm wrong!
Only container managed contexts can be transaction-scoped, so only Entity Managers that are injected with the @PersistenceContext annotation or it's XML equivalent may be transaction-scoped.