Class UserTransactionImpl

  • All Implemented Interfaces:
    jakarta.transaction.UserTransaction, Serializable, Referenceable

    public class UserTransactionImpl
    extends Object
    implements jakarta.transaction.UserTransaction, Referenceable, Serializable
    This class implements the jakarta.transaction.UserTransaction interface which defines methods that allow an application to explicitly manage transaction boundaries.
    Version:
    1.0 Feb 09, 1999
    Author:
    Ram Jeyaraman
    See Also:
    Serialized Form
    • Constructor Detail

      • UserTransactionImpl

        public UserTransactionImpl()
    • Method Detail

      • begin

        public void begin()
                   throws jakarta.transaction.NotSupportedException,
                          jakarta.transaction.SystemException
        Create a new transaction and associate it with the current thread.
        Specified by:
        begin in interface jakarta.transaction.UserTransaction
        Throws:
        IllegalStateException - Thrown if the thread is already associated with a transaction.
        jakarta.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition
        jakarta.transaction.NotSupportedException
      • commit

        public void commit()
                    throws jakarta.transaction.RollbackException,
                           jakarta.transaction.HeuristicMixedException,
                           jakarta.transaction.HeuristicRollbackException,
                           SecurityException,
                           IllegalStateException,
                           jakarta.transaction.SystemException
        Complete the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.
        Specified by:
        commit in interface jakarta.transaction.UserTransaction
        Throws:
        jakarta.transaction.TransactionRolledbackException - Thrown to indicate that the transaction has been rolled back rather than committed.
        jakarta.transaction.HeuristicMixedException - Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.
        jakarta.transaction.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.
        IllegalStateException - Thrown if the current thread is not associated with a transaction.
        jakarta.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition
        jakarta.transaction.RollbackException
      • rollback

        public void rollback()
                      throws IllegalStateException,
                             SecurityException,
                             jakarta.transaction.SystemException
        Roll back the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.
        Specified by:
        rollback in interface jakarta.transaction.UserTransaction
        Throws:
        SecurityException - Thrown to indicate that the thread is not allowed to roll back the transaction.
        IllegalStateException - Thrown if the current thread is not associated with a transaction.
        jakarta.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition
      • setRollbackOnly

        public void setRollbackOnly()
                             throws IllegalStateException,
                                    jakarta.transaction.SystemException
        Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
        Specified by:
        setRollbackOnly in interface jakarta.transaction.UserTransaction
        Throws:
        IllegalStateException - Thrown if the current thread is not associated with a transaction.
        jakarta.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition
      • getStatus

        public int getStatus()
                      throws jakarta.transaction.SystemException
        Obtain the status of the transaction associated with the current thread.
        Specified by:
        getStatus in interface jakarta.transaction.UserTransaction
        Returns:
        The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
        Throws:
        jakarta.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition
      • setTransactionTimeout

        public void setTransactionTimeout​(int seconds)
                                   throws jakarta.transaction.SystemException
        Modify the timeout value that is associated with transactions started by subsequent invocations of the begin method.

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

        Specified by:
        setTransactionTimeout in interface jakarta.transaction.UserTransaction
        Parameters:
        seconds - 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.
        Throws:
        jakarta.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.