Interface TransactionManager

All Known Implementing Classes:
LocalTransactionManager

public interface TransactionManager
A transaction manager.

The implementation instance must be thread safe.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    hasSavepoint(String savepointName)
    Whether the current transaction has the save point.
    boolean
    Whether the current transaction is marked to be undone.
    void
    Executes the transaction whose attribute is NOT_SUPPORTED.
    <RESULT> RESULT
    notSupported(Supplier<RESULT> supplier)
    Executes the transaction whose attribute is NOT_SUPPORTED and returns the result.
    void
    Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level.
    <RESULT> RESULT
    notSupported(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier)
    Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level and return the result.
    void
    releaseSavepoint(String savepointName)
    Removes the specified save point and subsequent save points from the current transaction.
    void
    Executes the transaction whose attribute is REQUIRED.
    <RESULT> RESULT
    required(Supplier<RESULT> supplier)
    Executes the transaction whose attribute is REQUIRED and returns the result.
    void
    Executes the transaction whose attribute is REQUIRED with the specified transaction isolation level.
    <RESULT> RESULT
    required(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier)
    Executes the transaction whose attribute is REQUIRED with the specified transaction isolation level and return the result.
    void
    Executes the transaction whose attribute is REQUIRES_NEW.
    <RESULT> RESULT
    requiresNew(Supplier<RESULT> supplier)
    Executes the transaction whose attribute is REQUIRES_NEW and returns the result.
    void
    Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level.
    <RESULT> RESULT
    requiresNew(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier)
    Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level and return the result.
    void
    rollback(String savepointName)
    Undoes all changes made after the given save point.
    void
    Marks the current transaction to undo in the end of the transaction.
    void
    setSavepoint(String savepointName)
    Creates a save point with the specified name.
  • Method Details

    • required

      void required(Runnable block)
      Executes the transaction whose attribute is REQUIRED.
      Parameters:
      block - the code that is executed in the transaction
    • required

      void required(TransactionIsolationLevel isolationLevel, Runnable block)
      Executes the transaction whose attribute is REQUIRED with the specified transaction isolation level.
      Parameters:
      isolationLevel - the transaction isolation level
      block - the code that is executed in the transaction
    • required

      <RESULT> RESULT required(Supplier<RESULT> supplier)
      Executes the transaction whose attribute is REQUIRED and returns the result.
      Type Parameters:
      RESULT - the result type
      Parameters:
      supplier - the code that is executed in the transaction
      Returns:
      the result
    • required

      <RESULT> RESULT required(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier)
      Executes the transaction whose attribute is REQUIRED with the specified transaction isolation level and return the result.
      Type Parameters:
      RESULT - the result type
      Parameters:
      isolationLevel - the transaction isolation level
      supplier - the code that is executed in the transaction
      Returns:
      the result
    • requiresNew

      void requiresNew(Runnable block)
      Executes the transaction whose attribute is REQUIRES_NEW.
      Parameters:
      block - the code that is executed in the transaction
    • requiresNew

      void requiresNew(TransactionIsolationLevel isolationLevel, Runnable block)
      Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level.
      Parameters:
      isolationLevel - the transaction isolation level
      block - the code that is executed in the transaction
    • requiresNew

      <RESULT> RESULT requiresNew(Supplier<RESULT> supplier)
      Executes the transaction whose attribute is REQUIRES_NEW and returns the result.
      Type Parameters:
      RESULT - the result type
      Parameters:
      supplier - the code that is executed in the transaction
      Returns:
      the result
    • requiresNew

      <RESULT> RESULT requiresNew(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier)
      Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level and return the result.
      Type Parameters:
      RESULT - the result type
      Parameters:
      isolationLevel - the transaction isolation level
      supplier - the code that is executed in the transaction
      Returns:
      the result
    • notSupported

      void notSupported(Runnable block)
      Executes the transaction whose attribute is NOT_SUPPORTED.
      Parameters:
      block - the code that is executed in the transaction
    • notSupported

      void notSupported(TransactionIsolationLevel isolationLevel, Runnable block)
      Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level.
      Parameters:
      isolationLevel - the transaction isolation level
      block - the code that is executed in the transaction
    • notSupported

      <RESULT> RESULT notSupported(Supplier<RESULT> supplier)
      Executes the transaction whose attribute is NOT_SUPPORTED and returns the result.
      Type Parameters:
      RESULT - the result type
      Parameters:
      supplier - the code that is executed in the transaction
      Returns:
      the result
    • notSupported

      <RESULT> RESULT notSupported(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier)
      Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level and return the result.
      Type Parameters:
      RESULT - the result type
      Parameters:
      isolationLevel - the transaction isolation level
      supplier - the code that is executed in the transaction
      Returns:
      the result
    • setRollbackOnly

      void setRollbackOnly()
      Marks the current transaction to undo in the end of the transaction.
    • isRollbackOnly

      boolean isRollbackOnly()
      Whether the current transaction is marked to be undone.
      Returns:
      true if the current transaction is marked.
    • setSavepoint

      void setSavepoint(String savepointName)
      Creates a save point with the specified name.

      Begin a transaction before invoking this method.

      Parameters:
      savepointName - the name of the save point
      Throws:
      DomaNullPointerException - if the savepointName is null
      TransactionNotYetBegunException - if the transaction is not begun
      SavepointAlreadyExistsException - if the save point already exists
      JdbcException - if a JDBC related error occurs
    • hasSavepoint

      boolean hasSavepoint(String savepointName)
      Whether the current transaction has the save point.

      Begin a transaction before invoking this method.

      Parameters:
      savepointName - the name of the save point
      Returns:
      true if the transaction has the save point
      Throws:
      DomaNullPointerException - if the savepointName is null
      TransactionNotYetBegunException - if the transaction is not begun
    • releaseSavepoint

      void releaseSavepoint(String savepointName)
      Removes the specified save point and subsequent save points from the current transaction.

      Begin a transaction before invoking this method.

      Parameters:
      savepointName - the name of the save point
      Throws:
      DomaNullPointerException - if the savepointName is null
      TransactionNotYetBegunException - if the transaction is not yet begun
      JdbcException - if a JDBC related error occurs
    • rollback

      void rollback(String savepointName)
      Undoes all changes made after the given save point.

      Begin a transaction before invoking this method.

      Parameters:
      savepointName - the name of the save point
      Throws:
      DomaNullPointerException - if the savepointName is null
      SavepointNotFoundException - if the save point is not found
      TransactionNotYetBegunException - if the transaction is not begun
      JdbcException - if a JDBC related error occurs