Class SimpleTransaction

java.lang.Object
com.gruelbox.transactionoutbox.spi.SimpleTransaction
All Implemented Interfaces:
Transaction, AutoCloseable

public final class SimpleTransaction extends Object implements Transaction, AutoCloseable
  • Constructor Details

    • SimpleTransaction

      public SimpleTransaction(Connection connection, Object context)
  • Method Details

    • connection

      public Connection connection()
      Specified by:
      connection in interface Transaction
      Returns:
      The connection for the transaction.
    • addPostCommitHook

      public void addPostCommitHook(Runnable runnable)
      Description copied from interface: Transaction
      Will be called to perform work immediately after the current transaction is committed. This should occur in the same thread and will generally not be long-lasting.
      Specified by:
      addPostCommitHook in interface Transaction
      Parameters:
      runnable - The code to run post-commit.
    • prepareBatchStatement

      public PreparedStatement prepareBatchStatement(String sql)
      Description copied from interface: Transaction
      Creates a prepared statement which will be cached and re-used within a transaction. Any batch on these statements is executed before the transaction is committed, and automatically closed.
      Specified by:
      prepareBatchStatement in interface Transaction
      Parameters:
      sql - The SQL statement
      Returns:
      The statement.
    • flushBatches

      public void flushBatches()
    • processHooks

      public void processHooks()
    • commit

      public void commit()
    • rollback

      public void rollback() throws SQLException
      Throws:
      SQLException
    • context

      public <T> T context()
      Specified by:
      context in interface Transaction
      Type Parameters:
      T - The context type. Coerced on read.
      Returns:
      A TransactionManager-specific object representing the context of this transaction. Intended for use with TransactionManager implementations that support explicitly-passed transaction context injection into method arguments.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable