
A transaction represents a sequence of operations treated as a unit to satisfy a request and to ensure database integrity. Transactions have the following features, known as ACID characteristics:
Atomicity
If the transaction fails, all effects it causes are rolled back. That is, either all changes made by a transaction are reflected on the data in the data store, or none of them.
Consistency
The effects of a transaction preserve database integrity.
Isolation
All transactions are executed independently of one another. The intermediate states of the transaction are not visible to other transactions.
Durability
The results of a transaction are durable and cannot be lost.
There are three types of transactions: flat transactions, chained transactions, and nested transactions. SAP NetWeaver Application Server Java supports flat transactions only.
In AS Java, the Transaction Service is responsible for transaction management. It controls the association and dissociation of the transactions to the thread context in which they are executed. In addition, the Transaction Service manages the life cycle of the transactions running on AS Java, and the propagation of the transaction context to other servers. The service comprises two modules - Java Transaction API (JTA) and Java Transaction Service (JTS) implementations.
More information:
AS Java provides support for both distributed and local transactions.
To provide flawless execution and no data loss in a distributed environment, the Transaction Service supports the two-phase commit (2PC) protocol for global transactions. The 2PC involves a preparation phase and a commit phase, which is completed only when all branches of the distributed transaction are prepared to commit. This preserves the atomicity of the distributed transactions and ensures the consistency of the data.
More information: Two-Phase Commit
The support for distributed transactions also enables you to use XA resources.
In the applications that access a database, you can use either JTA or local transactions.
More information: JTA and Local Transactions