...
Note | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1. The below annotation injects EntityManager object that corresponds to Tutorial persistence unit
2. The below annotation injects EntityManagerFactory object that corresponds to Account
|
...
Note | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1. The below declaration is for a persistence unit named Account and the transaction type is JTA.
2. The below declaration is for a persistence unit named Account and the transaction type is
Please note that there are two types of entity managers and corresponding persistence contexts. These are container managed entity manager and application managed entity manager. The container managed entity manager is the one whose persistence context is managed by container. The persistence context is propagated along the active transaction. The persistence scope of the container managed entity manager is transaction by default. The transaction type of the entity manager is always JTA. The EntityManager object is injected by the container to the application. The application managed entity manager is the one whose persistence context is managed by the application. The persistence context is not propagated along the transaction. The persistence context will be active even after the current transaction completes. The transaction type of the entity manager is RESOURCE_LOCAL by default. The EntityManager object should be created by using EntityManagerFactory object in the application. |
...