Package dev.getelements.elements.sdk.dao
Interface Transaction
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
MorphiaGuiceTransaction
Represents a transaction with
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes and releases the transaction.voidcommit()Commits the transaction.<DaoT> DaoTGets the requested Dao type, bound to thisTransaction.booleanisActive()Returns true if this transaction is still active and open.default <T> TperformAndClose(Function<Transaction, T> op) Performs the operation on thisTransaction, processing the result and returning the result of the operation.default voidPerforms the operation on thisTransaction, processing the result and returning the result of the operation.voidrollback()Rolls back the transaction.
-
Method Details
-
getDao
Gets the requested Dao type, bound to thisTransaction. The returned DAO is only valid for the life of thisTransactionobject.- Type Parameters:
DaoT- the DAO Type- Parameters:
daoT- theClass<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:
closein interfaceAutoCloseable
-
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
Performs the operation on thisTransaction, 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
Performs the operation on thisTransaction, processing the result and returning the result of the operation.- Parameters:
op- the operation
-