8.8.1 Attributes specified in the <persistence-unit> tag
In the <persistence-unit> tag, you specify the name attribute and transaction-type attribute.
- Organization of this subsection
(1) name attribute
You specify the name of the persistence unit to be defined. The name specified here is referenced from the unitName attribute of @PersistenceUnit or @PersistenceContext in the case of annotations. Also, in the case of the DD, the name specified here is referenced from the <persistence-unit-name> tag under the <persistence-context-ref> tag or under the <persistence-unit-ref> tag.
You cannot omit the name attribute. Also, when the JPA is used with Application Server, you cannot specify null in the name attribute. Specify a string of at least 1 character.
(2) transaction-type attribute
In the persistence unit to be defined, you specify whether the JTA will control the transaction or whether the application will control the transaction by using javax.persistence.EntityTransaction.
-
When the transaction is controlled by the JTA
Specify JTA in the transaction-type attribute. When you specify JTA, you must also specify the <jta-data-source> tag at the same time.
-
When the application controls the transaction by using EntityTransaction
Specify RESOURCE_LOCAL in the transaction-type attribute. When you specify RESOURCE_LOCAL, you must also specify the <non-jta-data-source> tag at the same time.
Note that if the transaction-type attribute is omitted, the default value is JTA.