Show Table of Contents
10.7.4. Nest Transactions
Nested transactions are only supported when you use distributed transactions, with the JTS API. In addition, many database vendors do not support nested transactions, so check with your database vendor before you add nested transactions to your application.
The OTS specifications allow for a limited type of nested transaction, where the subtransaction commit protocol is the same as a top-level transactions. There are two phases, a
prepare phase and a commit or abort phase. This type of nested transaction can lead to inconsistent results, such as in a scenario in which a subtransaction coordinator discovers part of the way through committing that a resources cannot commit. The coordinator may not be able to tell the committed resources to abort, and a heuristic outcome occurs. This strict OTS nested transaction is available via the CosTransactions::SubtransactionAwareResource interface.
The JBoss EAP 6 implementation of JTS supports this type of nested transaction. It also supports a type of nested transaction with a multi-phase commit protocol, which avoids the problems that are possible with the strict OTS model. This type of nested transaction is available via the
ArjunaOTS::ArjunaSubtranAwareResource. It is driven by a two-phase commit protocol whenever a nested transaction commits.
To create a nested transaction, you create a new transaction within a parent transaction. Refer to Section 10.7.3, “Begin a Transaction” for information on creating a transaction.
The effect of a nested transaction depends on upon the commit/roll back of its enclosing transactions. The effects are recovered if the enclosing transaction aborts, even if the nested transaction has committed.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.