Top Description Fields Constructors Methods
org.springframework.transaction.jta

public Class UserTransactionAdapter

extends Object
implements UserTransaction
Class Inheritance
All Implemented Interfaces
jakarta.transaction.UserTransaction
Imports
jakarta.transaction.HeuristicMixedException, .HeuristicRollbackException, .NotSupportedException, .RollbackException, .SystemException, .TransactionManager, .UserTransaction, org.springframework.util.Assert

Adapter for a JTA UserTransaction handle, taking a JTA jakarta.transaction.TransactionManager reference and creating a JTA jakarta.transaction.UserTransaction handle for it.

The JTA UserTransaction interface is an exact subset of the JTA TransactionManager interface. Unfortunately, it does not serve as super-interface of TransactionManager, though, which requires an adapter such as this class to be used when intending to talk to a TransactionManager handle through the UserTransaction interface.

Used internally by Spring's JtaTransactionManager for certain scenarios. Not intended for direct use in application code.

Author
Juergen Hoeller
Since
1.1.5

Field Summary

Modifier and TypeField and Description
private final TransactionManager

Constructor Summary

AccessConstructor and Description
public
UserTransactionAdapter(TransactionManager
the JTA TransactionManager to wrap
transactionManager
)

Create a new UserTransactionAdapter for the given TransactionManager.

Method Summary

Modifier and TypeMethod and Description
public void
begin()

Implements jakarta.transaction.UserTransaction.begin.

Create a new transaction and associate it with the current thread.
public void
commit()

Implements jakarta.transaction.UserTransaction.commit.

Complete the transaction associated with the current thread.
public int
getStatus()

Implements jakarta.transaction.UserTransaction.getStatus.

Obtain the status of the transaction associated with the current thread.
public final TransactionManager
getTransactionManager()

Return the JTA TransactionManager that this adapter delegates to.

public void
rollback()

Implements jakarta.transaction.UserTransaction.rollback.

Roll back the transaction associated with the current thread.
public void
setRollbackOnly()

Implements jakarta.transaction.UserTransaction.setRollbackOnly.

Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
public void
setTransactionTimeout(int
The value of the timeout in seconds. If the value is zero, the transaction service restores the default value. If the value is negative a SystemException is thrown.
timeout
)

Implements jakarta.transaction.UserTransaction.setTransactionTimeout.

Modify the timeout value that is associated with transactions started by the current thread with the begin method.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

transactionManagerback to summary
private final TransactionManager transactionManager

Constructor Detail

UserTransactionAdapterback to summary
public UserTransactionAdapter(TransactionManager transactionManager)

Create a new UserTransactionAdapter for the given TransactionManager.

Parameters
transactionManager:TransactionManager

the JTA TransactionManager to wrap

Method Detail

beginback to summary
public void begin() throws NotSupportedException, SystemException

Implements jakarta.transaction.UserTransaction.begin.

Doc from jakarta.transaction.UserTransaction.begin.

Create a new transaction and associate it with the current thread.

Annotations
@Override
Exceptions
NotSupportedException:
Thrown if the thread is already associated with a transaction and the Transaction Manager implementation does not support nested transactions.
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
commitback to summary
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException

Implements jakarta.transaction.UserTransaction.commit.

Doc from jakarta.transaction.UserTransaction.commit.

Complete the transaction associated with the current thread. When this method completes, the thread is no longer associated with a transaction.

Annotations
@Override
Exceptions
RollbackException:
Thrown to indicate that the transaction has been rolled back rather than committed.
HeuristicMixedException:
Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.
HeuristicRollbackException:
Thrown to indicate that a heuristic decision was made and that all relevant updates have been rolled back.
SecurityException:
Thrown to indicate that the thread is not allowed to commit the transaction.
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
getStatusback to summary
public int getStatus() throws SystemException

Implements jakarta.transaction.UserTransaction.getStatus.

Doc from jakarta.transaction.UserTransaction.getStatus.

Obtain the status of the transaction associated with the current thread.

Returns:int

The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.

Annotations
@Override
Exceptions
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
getTransactionManagerback to summary
public final TransactionManager getTransactionManager()

Return the JTA TransactionManager that this adapter delegates to.

rollbackback to summary
public void rollback() throws SecurityException, SystemException

Implements jakarta.transaction.UserTransaction.rollback.

Doc from jakarta.transaction.UserTransaction.rollback.

Roll back the transaction associated with the current thread. When this method completes, the thread is no longer associated with a transaction.

Annotations
@Override
Exceptions
SecurityException:
Thrown to indicate that the thread is not allowed to roll back the transaction.
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
setRollbackOnlyback to summary
public void setRollbackOnly() throws SystemException

Implements jakarta.transaction.UserTransaction.setRollbackOnly.

Doc from jakarta.transaction.UserTransaction.setRollbackOnly.

Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.

Annotations
@Override
Exceptions
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
setTransactionTimeoutback to summary
public void setTransactionTimeout(int timeout) throws SystemException

Implements jakarta.transaction.UserTransaction.setTransactionTimeout.

Doc from jakarta.transaction.UserTransaction.setTransactionTimeout.

Modify the timeout value that is associated with transactions started by the current thread with the begin method.

If an application has not called this method, the transaction service uses some default value for the transaction timeout.

Parameters
timeout:int

The value of the timeout in seconds. If the value is zero, the transaction service restores the default value. If the value is negative a SystemException is thrown.

Annotations
@Override
Exceptions
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.