Interface Transaction

All Superinterfaces:
AutoCloseable, TransactionContext

@NonExtendable public interface Transaction extends TransactionContext, AutoCloseable
An open transaction. Use try-with-resources: closing without commit() aborts.
try (Transaction tx = engine.transactions().openOuter()) {
    long moved = Transfers.move(source, target, filter, 1000, tx).moved();
    if (moved == 1000) tx.commit();
}

Simulation is a transaction that is aborted, so simulating and executing share one code path.

  • Method Details

    • commit

      void commit()
      Throws:
      IllegalStateException - if already closed or a nested transaction is still open
    • abort

      void abort()
      Throws:
      IllegalStateException - if already closed or a nested transaction is still open
    • isOpen

      boolean isOpen()
    • close

      void close()
      Aborts if still open.
      Specified by:
      close in interface AutoCloseable