Interface SimpleTransactionControl


  • public interface SimpleTransactionControl
    An interface implemented by transaction handles that provide direct/simple commit and rollback functionality.
    Author:
    David M. Lloyd
    • Method Detail

      • commit

        void commit()
             throws jakarta.transaction.RollbackException,
                    jakarta.transaction.HeuristicMixedException,
                    jakarta.transaction.HeuristicRollbackException,
                    SecurityException,
                    jakarta.transaction.SystemException
        Commit this transaction. Any provider-specific thread association with this transaction is cancelled regardless of the outcome of this method.
        Throws:
        jakarta.transaction.RollbackException - if the transaction was rolled back rather than committed
        jakarta.transaction.HeuristicMixedException - if a heuristic decision was made resulting in a mix of committed and rolled back resources
        jakarta.transaction.HeuristicRollbackException - if a heuristic decision was made and all resources were rolled back
        SecurityException - if the current thread or user is not authorized to modify the transaction
        jakarta.transaction.SystemException - if there is an unexpected error condition
      • rollback

        void rollback()
               throws SecurityException,
                      jakarta.transaction.SystemException
        Roll back this transaction. Any provider-specific thread association with this transaction is cancelled regardless of the outcome of this method.
        Throws:
        SecurityException - if the current thread or user is not authorized to modify the transaction
        jakarta.transaction.SystemException - if there is an unexpected error condition
      • setRollbackOnly

        default void setRollbackOnly()
                              throws jakarta.transaction.SystemException
        Set the transaction to be rollback-only. The transaction system is generally guaranteed to only call rollback() after this method, so its implementation is optional, however it may be useful to hint to the remote system that the transaction will only be rolled back.
        Throws:
        jakarta.transaction.SystemException - if an unexpected error occurs
      • safeRollback

        default void safeRollback()
        Safely roll back a transaction without throwing an exception; useful in cases where rollback failure is unrecoverable.
      • of

        static SimpleTransactionControl of​(jakarta.transaction.Transaction transaction)
        A simple transaction control facade over a transaction manager Transaction object.
        Parameters:
        transaction - the transaction (must not be null)
        Returns:
        the simple transaction control facade (not null)
      • getProviderInterface

        <T> T getProviderInterface​(Class<T> providerInterfaceType)
        Get a provider-specific interface from this transaction controller.
        Type Parameters:
        T - the provider interface type
        Parameters:
        providerInterfaceType - the provider interface type class (must not be null)
        Returns:
        the provider interface, or null if the given type isn't supported by this transaction's provider