Interface Repository.LifecycleManagement<ID,E>

Type Parameters:
ID - The type of identifier for entities in this repository.
E - The type of entity this repository stores.
All Superinterfaces:
DescribableComponent, Repository<ID,E>
All Known Implementing Classes:
AccessSerializingRepository, EventSourcingRepository, InMemoryRepository, SimpleRepository
Enclosing interface:
Repository<ID,E>

public static non-sealed interface Repository.LifecycleManagement<ID,E> extends Repository<ID,E>
Specialization of the Repository interface that must be implemented by all implementations of the Repository. It exposes some methods that are required to perform lifecycle management operations that are not typically required outside of repository implementation.

More specifically, these methods are meant for implementations of a Repository wrapping another to be able to properly have lifecycle operations registered with downstream Repository implementations.

  • Method Details

    • attach

      ManagedEntity<ID,E> attach(@Nonnull ManagedEntity<ID,E> entity, @Nonnull ProcessingContext processingContext)
      Ensures that the given entity has its lifecycle managed in the given processingContext. This ensures that when the processingContext commits, any changes detected in the entity state are persisted in this repository's underlying storage, if present.

      If a managed entity for this identifier was already present in the ProcessingContext, the new instance will replace it.

      Repositories may wrap entities. In that case, the returned instance may not be exactly the same (`==` comparison) as the instance provided. It is always recommended to use the returned instance.

      Parameters:
      entity - The entity to have its lifecycle attached to the given processing context.
      processingContext - The processing context to link the lifecycle with.
      Returns:
      The instance of the entity whose lifecycle is managed by this repository.