Java Reference
In-Depth Information
Java Transaction API 1.2
The Java Transaction API 1.2 Specification was developed under JSR 907. This sec-
tion just gives you an overview of improvement in the API. The complete document
specification (for more information) can be downloaded from
communityprocess/mrel/jsr907/index2.html .
The Java Transaction API
The Java Transaction API ( JTA ) is a standard Java API for managing transactions
on one or more resources (distributed transactions) in server environments. It consist
of three main APIs: javax.transaction.UserTransaction interface used by
applications for explicit transaction demarcation,
javax.transaction.TransactionManager interface used by application serv-
ers to demarcate transactions implicitly on behalf of the application, and
javax.transaction.xa.XAResource , which is a Java mapping of the standard
XA interface for distributed transaction processing.
JTA in action
As we said, JTA transactions are used in Java EE environments. In order to enable
this transaction type, the transaction-type attribute of the persistence unit should
be set to JTA instead of RESOURCE_LOCAL and the data source (if there is one),
should be defined within the <jta-datasource> element. The following code gives
an example of a persistence unit to manage transactions using JTA:
<?xml version="1.0" encoding="UTF-8"?>
Search WWH ::

Custom Search