Interface Transaction

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
MorphiaGuiceTransaction

public interface Transaction extends AutoCloseable
Represents a transaction with
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes and releases the transaction.
    void
    Commits the transaction.
    <DaoT> DaoT
    getDao(Class<DaoT> daoT)
    Gets the requested Dao type, bound to this Transaction.
    boolean
    Returns true if this transaction is still active and open.
    default <T> T
    Performs the operation on this Transaction, processing the result and returning the result of the operation.
    default void
    Performs the operation on this Transaction, processing the result and returning the result of the operation.
    void
    Rolls back the transaction.
  • Method Details

    • getDao

      <DaoT> DaoT getDao(Class<DaoT> daoT)
      Gets the requested Dao type, bound to this Transaction. The returned DAO is only valid for the life of this Transaction object.
      Type Parameters:
      DaoT - the DAO Type
      Parameters:
      daoT - the Class<DaoT>
      Returns:
      the DAO Instance
    • commit

      void commit()
      Commits the transaction.
    • rollback

      void rollback()
      Rolls back the transaction.
    • close

      void close()
      Closes and releases the transaction.
      Specified by:
      close in interface AutoCloseable
    • isActive

      boolean isActive()
      Returns true if this transaction is still active and open.
      Returns:
      true if active, false if it has been committed or rolled back.
    • performAndClose

      default <T> T performAndClose(Function<Transaction,T> op)
      Performs the operation on this Transaction, processing the result and returning the result of the operation.
      Type Parameters:
      T - the return type
      Parameters:
      op - the operation
      Returns:
      the result of the operation
    • performAndCloseV

      default void performAndCloseV(Consumer<Transaction> op)
      Performs the operation on this Transaction, processing the result and returning the result of the operation.
      Parameters:
      op - the operation