Interface ITransaction

All Known Implementing Classes:
ChildTransaction, Transaction

public interface ITransaction
A transaction interface which defines transaction management methods for JDBC connections.

There are two implementations of this interface: Transaction and ChildTransaction, which represent top-level and nested transactions respectively.

  • Method Details

    • setIsolationLevel

      ITransaction setIsolationLevel(int isolationLevel)
      Set isolation level.
      Returns:
      The transaction object for chainability.
    • getIsolationLevel

      int getIsolationLevel()
      Get the configured transaction isolation level.
    • getConnection

      Connection getConnection()
      Get (creating if none found) the connection associated with this transaction.

      This method should be called by queries executed inside a transaction body to ensure they run on the correct (transactional) connection. Upon first execution, this method will acquire a connection from the datasource and store it for further use within the transaction.

    • getDataSource

      DataSource getDataSource()
      Get the datasource associated with this transaction.

      Useful for checking that a given query is using the same datasource as its wrapping transaction.

    • begin

      ITransaction begin()
      Begin the transaction - essentially a no-nop, as the transaction is only started when the connection is first acquired. (think: when the first query is executed.)
    • commit

      ITransaction commit()
      Commit the transaction
      Returns:
      The transaction object for chainability.
    • rollback

      ITransaction rollback()
      Rollback the entire transaction. The transaction will be rolled back to the last committed point, and will ignore any set savepoints.
      Returns:
      The transaction object for chainability.
    • rollback

      ITransaction rollback(Key savepoint)
      Rollback the transaction up to the last (named) savepoint.
      Parameters:
      savepoint - The name of the savepoint to rollback to or NULL for no savepoint.
      Returns:
      The transaction object for chainability.
    • setSavepoint

      ITransaction setSavepoint(Key savepoint)
      Set a savepoint in the transaction
      Parameters:
      savepoint - The name of the savepoint
      Returns:
      The transaction object for chainability.
    • end

      Shutdown the transaction by re-enabling auto commit mode and closing the connection to the database (i.e. releasing it back to the connection pool from whence it came.)
      Returns:
      The transaction object for chainability.