Interface StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_TYPE>>

  • Type Parameters:
    ID - the type of id
    EVENT_TYPE - the type of event
    AGGREGATE_TYPE - the aggregate type
    All Superinterfaces:
    Aggregate<ID,​AGGREGATE_TYPE>
    All Known Implementing Classes:
    AggregateRoot, AggregateRoot, AggregateRootWithState

    public interface StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_TYPE>>
    extends Aggregate<ID,​AGGREGATE_TYPE>
    A stateful Aggregate is the most common form of Aggregate design in Object Oriented languages.
    What makes an Aggregate stateful is the fact that any changes, i.e. Events applied as the result of calling command methods on the aggregate instance, are stored within the StatefulAggregate prior to persisting the aggregate, and the events associated with any changes can be queried using getUncommittedChanges() and is reset (e.g. after a transaction/UnitOfWork has completed) using markChangesAsCommitted()

    See FlexAggregate for an immutable Aggregate design
    • Method Detail

      • getUncommittedChanges

        EventsToPersist<ID,​EVENT_TYPE> getUncommittedChanges()
        Query any changes to the Aggregate, i.e. Events applied as the result of calling command methods on the aggregate instance,
        Returns:
        the changes to the aggregate
      • markChangesAsCommitted

        void markChangesAsCommitted()
        Resets the getUncommittedChanges() - effectively marking them as having been persisted and committed to the underlying EventStore