このコンテンツは選択した言語では利用できません。
11.7.5. Commit a Transaction
This procedure shows how to commit a transaction using the Java Transaction API (JTA). This API is used for both local transactions and distributed transactions. Distributed transactions are managed by the Java Transaction Server (JTS) and require configuration of an Object Request Broker (ORB). For more information on ORB configuration, refer to the ORB Configuration section of the Administration and Configuration Guide.
Prerequisites
You must begin a transaction before you can commit it. For information on how to begin a transaction, refer to Section 11.7.3, “Begin a Transaction”.
Call the
commit()
method on theUserTransaction
.When you call thecommit()
method on theUserTransaction
, the Transaction Manager attempts to commit the transaction.Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use Container Managed Transactions (CMT), you do not need to manually commit.
If you configure your bean to use Container Managed Transactions, the container will manage the transaction lifecycle for you based on annotations you configure in the code.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Result
Your datasource commits and your transaction ends, or an exception is thrown.
Note
For a full example, see Section 11.9.3, “JTA Transaction Example”.