ScottM
ScottM

Reputation: 109

What does the "Use Java Transaction APIs" checkbox do in Netbeans persistence.xml

In Netbeans in the persistence.xml there is a checkbox called "Use Java Transaction API" this changes the xml from:

<persistence-unit name="PUNAME-PU" transaction-type="RESOURCE_LOCAL"> 

To:

<persistence-unit name="PUNAME-PU" transaction-type="JTA">

Is this for CMT vs BMT?

Upvotes: 1

Views: 1511

Answers (1)

JB Nizet
JB Nizet

Reputation: 692241

Here's what the JPA2 specification says about this attribute:

The transaction-type attribute is used to specify whether the entity managers provided by the entity manager factory for the persistence unit must be JTA entity managers or resource-local entity managers. The value of this element is JTA or RESOURCE_LOCAL. A transaction-type of JTA assumes that a JTA data source will be provided—either as specified by the jta-data-source element or provided by the container. In general, in Java EE environments, a transaction-type of RESOURCE_LOCAL assumes that a non-JTA datasource will be provided. In a Java EE environment, if this element is not specified, the default is JTA. In a Java SE environment, if this element is not specified, the default is RESOURCE_LOCAL.

And here is what it says about JTA and resource local entity managers:

JTA EntityManagers

An entity manager whose transactions are controlled through JTA is a JTA entity manager. A JTA entity manager participates in the current JTA transaction, which is begun and committed external to the entity manager and propagated to the underlying resource manager.

Resource-local EntityManagers

An entity manager whose transactions are controlled by the application through the EntityTransaction API is a resource-local entity manager. A resource-local entity manager transaction is mapped to a resource transaction over the resource by the persistence provider. Resource-local entity managers may use server or local resources to connect to the database and are unaware of the presence of JTA transactions that may or may not be active.

Upvotes: 2

Related Questions