Package dev.getelements.elements.sdk.dao
Interface Transaction
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
MorphiaGuiceTransaction
Represents a transaction with
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes and releases the transaction.void
commit()
Commits the transaction.<DaoT> DaoT
Gets the requested Dao type, bound to thisTransaction
.boolean
isActive()
Returns true if this transaction is still active and open.default <T> T
performAndClose
(Function<Transaction, T> op) Performs the operation on thisTransaction
, processing the result and returning the result of the operation.default void
Performs the operation on thisTransaction
, processing the result and returning the result of the operation.void
rollback()
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 thisTransaction
object.- 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:
close
in 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
-