Transaction

public abstract class Transaction<I, E extends TransactionalEntity<I, S, B>, S extends EntityState, B extends ValidatingBuilder<S>>

The abstract class for the entity transactions.

The transaction is a set of changes made to an entity state or entity attributes (e.g. version, lifecycle flags etc).

Serves as a buffer, accumulating the changes, intended for the enclosed Entity; the changes are only applied to the actual object upon commit.

The transaction is injected to the entity, which state should be modified. By doing so, the "buffering" builder is exposed to concrete TransactionalEntity subclasses. In turn, they receive an ability to change the entity state by modifying entity state builder.

Same applies to the entity lifecycle flags.

Version management is performed automatically by the transaction itself.

Parameters

<I>

the type of entity IDs

<E>

the type of entity

<S>

the type of entity state

<B>

the type of a ValidatingBuilder for the entity state

Inheritors

Constructors

Link copied to clipboard
protected void Transaction(E entity)
Creates a new instance of Transaction and injects the newly created transaction into the given entity.
protected void Transaction(E entity, S state, Version version)
Acts similar to an overloaded ctor, but instead of using the original entity state and version, this transaction will have the passed state and version as a starting point.

Functions

Link copied to clipboard
public final void commit()
Applies all the outstanding modifications to the enclosed entity.
Link copied to clipboard
protected final void commitAttributeChanges()
Applies lifecycle flag modifications to the entity under transaction.
Link copied to clipboard
public final void commitIfActive()
Commits this transaction if it is still active.
Link copied to clipboard
protected final E entity()
Link copied to clipboard
protected final DispatchOutcome propagate(Phase<I> phase)
Propagates a phase and performs a rollback in case of an error.
Link copied to clipboard
protected final void setArchived(boolean archived)
Set archived lifecycle flag to the passed value.
Link copied to clipboard
protected final void setDeleted(boolean deleted)
Set deleted lifecycle flag to the passed value.
Link copied to clipboard
public final void setListener(TransactionListener<I> listener)
Injects a listener into this transaction.