Interface JdbcAggregateOperations

All Known Implementing Classes:
JdbcAggregateTemplate

public interface JdbcAggregateOperations
Specifies a operations one can perform on a database, based on an Domain Type.
Author:
Jens Schauder, Thomas Lang, Milan Milanov
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    count(Class<?> domainType)
    Counts the number of aggregates of a given type.
    <T> void
    delete(T aggregateRoot, Class<T> domainType)
    Delete an aggregate identified by it's aggregate root.
    void
    deleteAll(Class<?> domainType)
    Delete all aggregates of a given type.
    <T> void
    deleteById(Object id, Class<T> domainType)
    Deletes a single Aggregate including all entities contained in that aggregate.
    <T> boolean
    existsById(Object id, Class<T> domainType)
    Checks if an aggregate identified by type and id exists in the database.
    <T> Iterable<T>
    findAll(Class<T> domainType)
    Load all aggregates of a given type.
    <T> Page<T>
    findAll(Class<T> domainType, Pageable pageable)
    Load a page of (potentially sorted) aggregates of a given type.
    <T> Iterable<T>
    findAll(Class<T> domainType, Sort sort)
    Load all aggregates of a given type, sorted.
    <T> Iterable<T>
    findAllById(Iterable<?> ids, Class<T> domainType)
    Load all aggregates of a given type that are identified by the given ids.
    <T> T
    findById(Object id, Class<T> domainType)
    Load an aggregate from the database.
    <T> T
    insert(T instance)
    Dedicated insert function.
    <T> T
    save(T instance)
    Saves an instance of an aggregate, including all the members of the aggregate.
    <T> T
    update(T instance)
    Dedicated update function.
  • Method Details

    • save

      <T> T save(T instance)
      Saves an instance of an aggregate, including all the members of the aggregate.
      Type Parameters:
      T - the type of the aggregate root.
      Parameters:
      instance - the aggregate root of the aggregate to be saved. Must not be null.
      Returns:
      the saved instance.
    • insert

      <T> T insert(T instance)
      Dedicated insert function. This skips the test if the aggregate root is new and makes an insert.

      This is useful if the client provides an id for new aggregate roots.

      Type Parameters:
      T - the type of the aggregate root.
      Parameters:
      instance - the aggregate root of the aggregate to be inserted. Must not be null.
      Returns:
      the saved instance.
    • update

      <T> T update(T instance)
      Dedicated update function. This skips the test if the aggregate root is new or not and always performs an update operation.
      Type Parameters:
      T - the type of the aggregate root.
      Parameters:
      instance - the aggregate root of the aggregate to be inserted. Must not be null.
      Returns:
      the saved instance.
    • deleteById

      <T> void deleteById(Object id, Class<T> domainType)
      Deletes a single Aggregate including all entities contained in that aggregate.
      Type Parameters:
      T - the type of the aggregate root.
      Parameters:
      id - the id of the aggregate root of the aggregate to be deleted. Must not be null.
      domainType - the type of the aggregate root.
    • delete

      <T> void delete(T aggregateRoot, Class<T> domainType)
      Delete an aggregate identified by it's aggregate root.
      Type Parameters:
      T - the type of the aggregate root.
      Parameters:
      aggregateRoot - to delete. Must not be null.
      domainType - the type of the aggregate root. Must not be null.
    • deleteAll

      void deleteAll(Class<?> domainType)
      Delete all aggregates of a given type.
      Parameters:
      domainType - type of the aggregate roots to be deleted. Must not be null.
    • count

      long count(Class<?> domainType)
      Counts the number of aggregates of a given type.
      Parameters:
      domainType - the type of the aggregates to be counted.
      Returns:
      the number of instances stored in the database. Guaranteed to be not null.
    • findById

      @Nullable <T> T findById(Object id, Class<T> domainType)
      Load an aggregate from the database.
      Type Parameters:
      T - the type of the aggregate root.
      Parameters:
      id - the id of the aggregate to load. Must not be null.
      domainType - the type of the aggregate root. Must not be null.
      Returns:
      the loaded aggregate. Might return null.
    • findAllById

      <T> Iterable<T> findAllById(Iterable<?> ids, Class<T> domainType)
      Load all aggregates of a given type that are identified by the given ids.
      Type Parameters:
      T - the type of the aggregate roots. Must not be null.
      Parameters:
      ids - of the aggregate roots identifying the aggregates to load. Must not be null.
      domainType - the type of the aggregate roots. Must not be null.
      Returns:
      Guaranteed to be not null.
    • findAll

      <T> Iterable<T> findAll(Class<T> domainType)
      Load all aggregates of a given type.
      Type Parameters:
      T - the type of the aggregate roots. Must not be null.
      Parameters:
      domainType - the type of the aggregate roots. Must not be null.
      Returns:
      Guaranteed to be not null.
    • existsById

      <T> boolean existsById(Object id, Class<T> domainType)
      Checks if an aggregate identified by type and id exists in the database.
      Type Parameters:
      T - the type of the aggregate root.
      Parameters:
      id - the id of the aggregate root.
      domainType - the type of the aggregate root.
      Returns:
      whether the aggregate exists.
    • findAll

      <T> Iterable<T> findAll(Class<T> domainType, Sort sort)
      Load all aggregates of a given type, sorted.
      Type Parameters:
      T - the type of the aggregate roots. Must not be null.
      Parameters:
      domainType - the type of the aggregate roots. Must not be null.
      sort - the sorting information. Must not be null.
      Returns:
      Guaranteed to be not null.
      Since:
      2.0
    • findAll

      <T> Page<T> findAll(Class<T> domainType, Pageable pageable)
      Load a page of (potentially sorted) aggregates of a given type.
      Type Parameters:
      T - the type of the aggregate roots. Must not be null.
      Parameters:
      domainType - the type of the aggregate roots. Must not be null.
      pageable - the pagination information. Must not be null.
      Returns:
      Guaranteed to be not null.
      Since:
      2.0