Interface UnitOfWork
-
- All Known Subinterfaces:
ClientSessionAwareUnitOfWork,HandleAwareUnitOfWork
- All Known Implementing Classes:
GenericHandleAwareUnitOfWorkFactory.GenericHandleAwareUnitOfWork,SpringMongoTransactionAwareUnitOfWorkFactory.SpringMongoTransactionAwareUnitOfWork,SpringTransactionAwareJdbiUnitOfWorkFactory.SpringTransactionAwareHandleAwareUnitOfWork,SpringTransactionAwareUnitOfWork
public interface UnitOfWork
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcommit()Commit theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.CommittedExceptiongetCauseOfRollback()The cause of a Rollback or amarkAsRollbackOnly(Exception)default voidmarkAsRollbackOnly()voidmarkAsRollbackOnly(Exception cause)<T> TregisterLifecycleCallbackForResource(T resource, UnitOfWorkLifecycleCallback<T> associatedUnitOfWorkCallback)TODO: Adjust example to the new API Register a resource (e.g.default voidrollback()Roll back theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.RolledBackvoidrollback(Exception cause)Roll back theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.RolledBackvoidstart()Start theUnitOfWorkand any underlying transactionUnitOfWorkStatusstatus()Get the status of theUnitOfWork
-
-
-
Method Detail
-
start
void start()
Start theUnitOfWorkand any underlying transaction
-
commit
void commit()
Commit theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.Committed
-
rollback
void rollback(Exception cause)
Roll back theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.RolledBack- Parameters:
cause- the cause of the rollback
-
status
UnitOfWorkStatus status()
Get the status of theUnitOfWork
-
getCauseOfRollback
Exception getCauseOfRollback()
The cause of a Rollback or amarkAsRollbackOnly(Exception)
-
markAsRollbackOnly
default void markAsRollbackOnly()
-
markAsRollbackOnly
void markAsRollbackOnly(Exception cause)
-
rollback
default void rollback()
Roll back theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.RolledBack
-
registerLifecycleCallbackForResource
<T> T registerLifecycleCallbackForResource(T resource, UnitOfWorkLifecycleCallback<T> associatedUnitOfWorkCallback)TODO: Adjust example to the new API Register a resource (e.g. an Aggregate) that should have itsUnitOfWorkLifecycleCallbackcalled duringUnitOfWorkoperation.
Example:
Where the AggregAggregate aggregate = unitOfWork.registerLifecycleCallbackForResource(aggregate.loadFromEvents(event), new AggregateRootRepositoryUnitOfWorkLifecycleCallback()));{@code class AggregateRootRepositoryUnitOfWorkLifecycleCallback implements UnitOfWorkLifecycleCallback{ - Type Parameters:
T- the type of resource- Parameters:
resource- the resource that should be trackedassociatedUnitOfWorkCallback- the callback instance for the given resource- Returns:
- the
resourceor a proxy to it
-
-