Interface StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      Class<ID> aggregateIdType()
      The type of aggregate ID this repository uses
      Class<AGGREGATE_IMPL_TYPE> aggregateRootImplementationType()
      The type of StatefulAggregate implementation this repository handles
      dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType()
      The type of AggregateType this repository is using to persist Events
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration.
      This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
      If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration.
      This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
      If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
      This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
      If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
      This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
      If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>>
      StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>
      from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
      Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
      default AGGREGATE_IMPL_TYPE load​(ID aggregateId)
      Load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
      The loaded aggregate instance will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
      default AGGREGATE_IMPL_TYPE load​(ID aggregateId, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)
      Load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
      The loaded aggregate instance will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
      default void persist​(AGGREGATE_IMPL_TYPE aggregate)
      Deprecated.
      AGGREGATE_IMPL_TYPE save​(AGGREGATE_IMPL_TYPE aggregate)
      Save/Associate a newly created and not yet persisted StatefulAggregate instance with the UnitOfWorkFactory.getRequiredUnitOfWork()
      Any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
      default Optional<AGGREGATE_IMPL_TYPE> tryLoad​(ID aggregateId)
      Try to load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
      If the aggregate instance exists it will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
      default Optional<AGGREGATE_IMPL_TYPE> tryLoad​(ID aggregateId, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)
      Try to load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
      If the aggregate instance exists it will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
      Optional<AGGREGATE_IMPL_TYPE> tryLoad​(ID aggregateId, Optional<dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder> expectedLatestEventOrder)
      Try to load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
      If the aggregate instance exists it will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
    • Method Detail

      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   CONFIG eventStreamConfiguration,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration.
        This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        eventStreamConfiguration - the configuration for the event stream that will contain all the events related to the aggregate type
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateImplementationType - the concrete aggregate implementation type (MUST be a subtype of StatefulAggregate).
        It will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   CONFIG eventStreamConfiguration,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType,
                                                                                                                                                                                                                                                                                                                                                                   AggregateSnapshotRepository aggregateSnapshotRepository)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration.
        This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        eventStreamConfiguration - the configuration for the event stream that will contain all the events related to the aggregate type
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateImplementationType - the concrete aggregate implementation type (MUST be a subtype of StatefulAggregate).
        It will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        aggregateSnapshotRepository - optional (may be null) AggregateSnapshotRepository
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
        This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        aggregateType - the aggregate type being handled by this repository
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateImplementationType - the concrete aggregate implementation type (MUST be a subtype of StatefulAggregate).
        It will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType,
                                                                                                                                                                                                                                                                                                                                                                   AggregateSnapshotRepository aggregateSnapshotRepository)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
        This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        If that fails please use from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        aggregateType - the aggregate type being handled by this repository
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateImplementationType - the concrete aggregate implementation type (MUST be a subtype of StatefulAggregate).
        It will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
        aggregateSnapshotRepository - optional (may be null) AggregateSnapshotRepository
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   CONFIG eventStreamConfiguration,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<ID> aggregateIdType,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        eventStreamConfiguration - the configuration for the event stream that will contain all the events related to the aggregate type
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateIdType - the concrete aggregate ID type
        aggregateImplementationType - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   CONFIG eventStreamConfiguration,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<ID> aggregateIdType,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType,
                                                                                                                                                                                                                                                                                                                                                                   AggregateSnapshotRepository aggregateSnapshotRepository)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - the EventStore will be configured with the supplied eventStreamConfiguration
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        eventStreamConfiguration - the configuration for the event stream that will contain all the events related to the aggregate type
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateIdType - the concrete aggregate ID type
        aggregateImplementationType - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        aggregateSnapshotRepository - optional (may be null) AggregateSnapshotRepository
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<ID> aggregateIdType,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        aggregateType - the aggregate type being handled by this repository
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateIdType - the concrete aggregate ID type
        aggregateImplementationType - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • from

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,​EVENT_TYPE,​AGGREGATE_IMPL_TYPE> from​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                                                                                                   dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType,
                                                                                                                                                                                                                                                                                                                                                                   StatefulAggregateInstanceFactory aggregateRootInstanceFactory,
                                                                                                                                                                                                                                                                                                                                                                   Class<ID> aggregateIdType,
                                                                                                                                                                                                                                                                                                                                                                   Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType,
                                                                                                                                                                                                                                                                                                                                                                   AggregateSnapshotRepository aggregateSnapshotRepository)
        Create an StatefulAggregateRepository instance that supports loading and persisting the given Aggregate type - if missing, the EventStore will be configured with the default AggregateEventStreamConfiguration based on the AggregateEventStreamConfigurationFactory that the EventStore's AggregateEventStreamPersistenceStrategy is configured with
        Type Parameters:
        CONFIG - the aggregate type configuration
        ID - the aggregate ID type
        EVENT_TYPE - the type of event
        AGGREGATE_IMPL_TYPE - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        Parameters:
        eventStore - the EventStore instance to use
        aggregateType - the aggregate type being handled by this repository
        aggregateRootInstanceFactory - the factory responsible for instantiating your StatefulAggregate's when loading them from the EventStore
        aggregateIdType - the concrete aggregate ID type
        aggregateImplementationType - the concrete aggregate type (MUST be a subtype of StatefulAggregate)
        aggregateSnapshotRepository - optional (may be null) AggregateSnapshotRepository
        Returns:
        a repository instance that can be used load, add and query aggregates of type aggregateType
      • tryLoad

        default Optional<AGGREGATE_IMPL_TYPE> tryLoad​(ID aggregateId,
                                                      dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)
        Try to load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
        If the aggregate instance exists it will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
        Parameters:
        aggregateId - the id of the aggregate we want to load
        expectedLatestEventOrder - the expected Event.eventOrder() of the last event stored in relation to the given aggregate instance
        Returns:
        an Optional with the matching StatefulAggregate instance if it exists, otherwise it will return an Optional.empty()
        Throws:
        OptimisticAggregateLoadException - in case the Event.eventOrder() of the last event stored in relation to the given aggregate instance is different from the expectedLatestEventOrder
      • tryLoad

        Optional<AGGREGATE_IMPL_TYPE> tryLoad​(ID aggregateId,
                                              Optional<dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder> expectedLatestEventOrder)
        Try to load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
        If the aggregate instance exists it will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
        Parameters:
        aggregateId - the id of the aggregate we want to load
        expectedLatestEventOrder - option with the expected Event.eventOrder() of the last event stored in relation to the given aggregate instance (if any)
        Returns:
        an Optional with the matching StatefulAggregate instance if it exists, otherwise it will return an Optional.empty()
        Throws:
        OptimisticAggregateLoadException - in case the Event.eventOrder() of the last event stored in relation to the given aggregate instance is different from the expectedLatestEventOrder
      • tryLoad

        default Optional<AGGREGATE_IMPL_TYPE> tryLoad​(ID aggregateId)
        Try to load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
        If the aggregate instance exists it will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
        Parameters:
        aggregateId - the id of the aggregate we want to load
        Returns:
        an Optional with the matching StatefulAggregate instance if it exists, otherwise it will return an Optional.empty()
        Throws:
        OptimisticAggregateLoadException - in case the Event.eventOrder() of the last event stored in relation to the given aggregate instance is different from the expectedLatestEventOrder
      • load

        default AGGREGATE_IMPL_TYPE load​(ID aggregateId)
        Load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
        The loaded aggregate instance will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
        Parameters:
        aggregateId - the id of the aggregate we want to load
        Returns:
        an Optional with the matching StatefulAggregate instance
        Throws:
        dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.AggregateNotFoundException - in case a matching StatefulAggregate doesn't exist in the EventStore
      • load

        default AGGREGATE_IMPL_TYPE load​(ID aggregateId,
                                         dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)
        Load an StatefulAggregate instance with the specified aggregateId from the underlying EventStore
        The loaded aggregate instance will be associated with the UnitOfWorkFactory.getRequiredUnitOfWork() and any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
        Parameters:
        aggregateId - the id of the aggregate we want to load
        expectedLatestEventOrder - the expected Event.eventOrder() of the last event stored in relation to the given aggregate instance
        Returns:
        an Optional with the matching StatefulAggregate instance
        Throws:
        dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.AggregateNotFoundException - in case a matching StatefulAggregate doesn't exist in the EventStore
      • save

        AGGREGATE_IMPL_TYPE save​(AGGREGATE_IMPL_TYPE aggregate)
        Save/Associate a newly created and not yet persisted StatefulAggregate instance with the UnitOfWorkFactory.getRequiredUnitOfWork()
        Any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
        Parameters:
        aggregate - the aggregate instance to persist to the underlying EventStore
        Returns:
        the persisted aggregate
      • persist

        @Deprecated
        default void persist​(AGGREGATE_IMPL_TYPE aggregate)
        Deprecated.
        Save/Associate a newly created and not yet persisted StatefulAggregate instance with the UnitOfWorkFactory.getRequiredUnitOfWork()
        Any changes to will be tracked and will be persisted to the underlying EventStore when the UnitOfWork is committed.
        Parameters:
        aggregate - the aggregate instance to persist to the underlying EventStore
      • aggregateIdType

        Class<ID> aggregateIdType()
        The type of aggregate ID this repository uses
      • aggregateType

        dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType()
        The type of AggregateType this repository is using to persist Events