Class JdbcAggregateTemplate

java.lang.Object
org.springframework.data.jdbc.core.JdbcAggregateTemplate
All Implemented Interfaces:
JdbcAggregateOperations

public class JdbcAggregateTemplate extends Object implements JdbcAggregateOperations
JdbcAggregateOperations implementation, storing aggregates in and obtaining them from a JDBC data store.
Author:
Jens Schauder, Mark Paluch, Thomas Lang, Christoph Strobl, Milan Milanov, Myeonghyeon Lee
  • Constructor Details

  • Method Details

    • setEntityCallbacks

      public void setEntityCallbacks(EntityCallbacks entityCallbacks)
      Parameters:
      entityCallbacks -
      Since:
      1.1
    • save

      public <T> T save(T instance)
      Description copied from interface: JdbcAggregateOperations
      Saves an instance of an aggregate, including all the members of the aggregate.
      Specified by:
      save in interface JdbcAggregateOperations
      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

      public <T> T insert(T instance)
      Dedicated insert function to do just the insert of an instance of an aggregate, including all the members of the aggregate.
      Specified by:
      insert in interface JdbcAggregateOperations
      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

      public <T> T update(T instance)
      Dedicated update function to do just an update of an instance of an aggregate, including all the members of the aggregate.
      Specified by:
      update in interface JdbcAggregateOperations
      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.
    • count

      public long count(Class<?> domainType)
      Description copied from interface: JdbcAggregateOperations
      Counts the number of aggregates of a given type.
      Specified by:
      count in interface JdbcAggregateOperations
      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

      public <T> T findById(Object id, Class<T> domainType)
      Description copied from interface: JdbcAggregateOperations
      Load an aggregate from the database.
      Specified by:
      findById in interface JdbcAggregateOperations
      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.
    • existsById

      public <T> boolean existsById(Object id, Class<T> domainType)
      Description copied from interface: JdbcAggregateOperations
      Checks if an aggregate identified by type and id exists in the database.
      Specified by:
      existsById in interface JdbcAggregateOperations
      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

      public <T> Iterable<T> findAll(Class<T> domainType, Sort sort)
      Description copied from interface: JdbcAggregateOperations
      Load all aggregates of a given type, sorted.
      Specified by:
      findAll in interface JdbcAggregateOperations
      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.
    • findAll

      public <T> Page<T> findAll(Class<T> domainType, Pageable pageable)
      Description copied from interface: JdbcAggregateOperations
      Load a page of (potentially sorted) aggregates of a given type.
      Specified by:
      findAll in interface JdbcAggregateOperations
      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.
    • findAll

      public <T> Iterable<T> findAll(Class<T> domainType)
      Description copied from interface: JdbcAggregateOperations
      Load all aggregates of a given type.
      Specified by:
      findAll in interface JdbcAggregateOperations
      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.
    • findAllById

      public <T> Iterable<T> findAllById(Iterable<?> ids, Class<T> domainType)
      Description copied from interface: JdbcAggregateOperations
      Load all aggregates of a given type that are identified by the given ids.
      Specified by:
      findAllById in interface JdbcAggregateOperations
      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.
    • delete

      public <S> void delete(S aggregateRoot, Class<S> domainType)
      Description copied from interface: JdbcAggregateOperations
      Delete an aggregate identified by it's aggregate root.
      Specified by:
      delete in interface JdbcAggregateOperations
      Type Parameters:
      S - 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.
    • deleteById

      public <S> void deleteById(Object id, Class<S> domainType)
      Description copied from interface: JdbcAggregateOperations
      Deletes a single Aggregate including all entities contained in that aggregate.
      Specified by:
      deleteById in interface JdbcAggregateOperations
      Type Parameters:
      S - 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.
    • deleteAll

      public void deleteAll(Class<?> domainType)
      Description copied from interface: JdbcAggregateOperations
      Delete all aggregates of a given type.
      Specified by:
      deleteAll in interface JdbcAggregateOperations
      Parameters:
      domainType - type of the aggregate roots to be deleted. Must not be null.