8.4.3 Transaction control and EntityManager
The following two types of EntityManager are available depending on how the transactions are controlled:
-
JTA entity manager
EntityManager in which the transactions are controlled by the JTA.
-
Resource local entity manager
EntityManager in which the transactions are controlled by the EntityTransaction API.
The following table describes the relationship between the types of EntityManager and the transaction control methods.
|
Types of EntityManager |
Transaction control method |
|
|---|---|---|
|
JTA |
Resource local |
|
|
Container-managed EntityManager |
Y#1 |
N |
|
Application-managed EntityManager #2 |
Y |
Y |
- Legend:
-
Y: Transaction can be controlled
N: Transaction cannot be controlled
JTA: JTA entity manager
Resource local: Resource local entity manager
- #1
-
The transaction is necessarily controlled by the JTA.
- #2
-
You can select whether to control the transaction using the JTA or whether the application controls the transaction, by explicitly using the EntityTransaction API. When the EntityTransaction API is used, the transaction becomes a resource local transaction. Even if the JTA transaction exists, the transaction is controlled regardless of the JTA transaction.
You specify whether you want to use the JTA entity manager or the resource local entity manager in the definition of the persistence unit. For details on how to specify definitions in the persistence unit, see 8.8.1(2) transaction-type attribute.