Interface AggregateRepository<T,​K>

  • Type Parameters:
    T - @Aggregate class.
    K - @AggregateIdentifier class.
    All Known Implementing Classes:
    CrudAggregateRepository

    public interface AggregateRepository<T,​K>
    Default contract to the @Aggregate repository.
    Author:
    Thiago A. de Souza Weber
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      Long count​(String clause, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Returns total registers of a table, matching the given clause and arguments or 0 if none found.
      void delete​(K identifier)
      Delete the @Aggregate with the given identifier.
      boolean exists​(String clause, Object... arguments)
      Checks if, at least one, @Aggregate exists matching the given clause and arguments.
      boolean exists​(String clause, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Checks if, at least one, @Aggregate exists matching the given clause and arguments.
      boolean exists​(K identifier)
      Checks if the @Aggregate exists with the given identifier.
      com.totvs.tjf.core.aggregate.repository.AggregateCollectionResult<T> findAll​(String clause, String orderby, Integer limit, Integer offset, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
      Collection<T> findAll​(String clause, String orderby, Object... arguments)
      Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
      Collection<T> findAll​(String clause, String orderby, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
      Collection<T> findAll​(String clause, javax.persistence.LockModeType lockModeType, String orderby, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
      default com.totvs.tjf.core.aggregate.repository.AggregateCollectionResult<T> findAll​(org.springframework.data.domain.Pageable pageable, String clause, String orderby, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
      Optional<T> findOne​(String clause, Object... arguments)
      Returns a single @Aggregate, matching the given clause and arguments or Optional.empty() if none found.
      Optional<T> findOne​(String clause, javax.persistence.LockModeType lockModeType, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Returns a single @Aggregate, matching the given clause and arguments or Optional.empty() if none found.
      Optional<T> findOne​(String clause, org.springframework.jdbc.core.SqlParameterValue... arguments)
      Returns a single @Aggregate, matching the given clause and arguments or Optional.empty() if none found.
      Optional<T> get​(K identifier)
      Returns a single @Aggregate, matching the given identifier or Optional.empty() if none found.
      Optional<AggregateMetadataInfoContent> getMetadata​(K identifier)
      Returns the aggregate AggregateMetadataInfoContent, matching the given identifier or Optional.empty() if none found.
      T insert​(T aggregate)
      Serialize the given @Aggregate state and store at the database as a document.
      T update​(T aggregate)
      Serialize the given @Aggregate state and update document in the database .
    • Method Detail

      • exists

        boolean exists​(K identifier)
        Checks if the @Aggregate exists with the given identifier.
        Parameters:
        identifier - can't be null.
        Returns:
        true if exists, otherwise false.
      • exists

        boolean exists​(@Nullable
                       String clause,
                       @Nullable
                       Object... arguments)
        Checks if, at least one, @Aggregate exists matching the given clause and arguments.
        Parameters:
        clause - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        true if found at least one, otherwise false.
      • exists

        boolean exists​(@Nullable
                       String clause,
                       @Nullable
                       org.springframework.jdbc.core.SqlParameterValue... arguments)
        Checks if, at least one, @Aggregate exists matching the given clause and arguments.
        Parameters:
        clause - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        true if found at least one, otherwise false.
      • get

        Optional<T> get​(K identifier)
        Returns a single @Aggregate, matching the given identifier or Optional.empty() if none found.
        Parameters:
        identifier - can't be null.
        Returns:
        an Optional instance with the @Aggregate if found, otherwise Optional.empty().
      • findOne

        Optional<T> findOne​(@Nullable
                            String clause,
                            @Nullable
                            Object... arguments)
        Returns a single @Aggregate, matching the given clause and arguments or Optional.empty() if none found.
        Parameters:
        clause - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        an Optional instance with the @Aggregate if found any, otherwise Optional.empty().
      • findOne

        Optional<T> findOne​(@Nullable
                            String clause,
                            @Nullable
                            org.springframework.jdbc.core.SqlParameterValue... arguments)
        Returns a single @Aggregate, matching the given clause and arguments or Optional.empty() if none found.
        Parameters:
        clause - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        an Optional instance with the @Aggregate if found any, otherwise Optional.empty().
      • findOne

        Optional<T> findOne​(@Nullable
                            String clause,
                            javax.persistence.LockModeType lockModeType,
                            @Nullable
                            org.springframework.jdbc.core.SqlParameterValue... arguments)
        Returns a single @Aggregate, matching the given clause and arguments or Optional.empty() if none found.
        Parameters:
        clause - can be null.
        lockModeType - pass lock mode type if necessary.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        an Optional instance with the @Aggregate if found any, otherwise Optional.empty().
      • findAll

        Collection<T> findAll​(@Nullable
                              String clause,
                              @Nullable
                              String orderby,
                              @Nullable
                              Object... arguments)
        Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
        Parameters:
        clause - can be null.
        orderby - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        a Collection instance with all the @Aggregate found, otherwise Collections.emptyList().
      • findAll

        Collection<T> findAll​(@Nullable
                              String clause,
                              @Nullable
                              String orderby,
                              @Nullable
                              org.springframework.jdbc.core.SqlParameterValue... arguments)
        Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
        Parameters:
        clause - can be null.
        orderby - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        a Collection instance with all the @Aggregate found, otherwise Collections.emptyList().
      • findAll

        com.totvs.tjf.core.aggregate.repository.AggregateCollectionResult<T> findAll​(@Nullable
                                                                                     String clause,
                                                                                     @Nullable
                                                                                     String orderby,
                                                                                     @Nullable
                                                                                     Integer limit,
                                                                                     @Nullable
                                                                                     Integer offset,
                                                                                     @Nullable
                                                                                     org.springframework.jdbc.core.SqlParameterValue... arguments)
        Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
        Parameters:
        clause - can be null.
        orderby - can be null.
        limit - can be null.
        offset - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        a AggregateCollectionResult instance with all the @Aggregate found, otherwise items Collections.emptyList().
      • findAll

        default com.totvs.tjf.core.aggregate.repository.AggregateCollectionResult<T> findAll​(@Nullable
                                                                                             org.springframework.data.domain.Pageable pageable,
                                                                                             @Nullable
                                                                                             String clause,
                                                                                             @Nullable
                                                                                             String orderby,
                                                                                             @Nullable
                                                                                             org.springframework.jdbc.core.SqlParameterValue... arguments)
        Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
        Parameters:
        pageable - can be null.
        clause - can be null.
        orderby - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        a AggregateCollectionResult instance with all the @Aggregate found, otherwise items Collections.emptyList().
      • findAll

        Collection<T> findAll​(@Nullable
                              String clause,
                              javax.persistence.LockModeType lockModeType,
                              @Nullable
                              String orderby,
                              @Nullable
                              org.springframework.jdbc.core.SqlParameterValue... arguments)
        Returns all @Aggregates, matching the given clause and arguments or Collections.emptyList() if none found.
        Parameters:
        clause - can be null.
        lockModeType - pass lock mode type if necessary.
        orderby - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        a Collection instance with all the @Aggregate found, otherwise Collections.emptyList().
      • insert

        T insert​(T aggregate)
        Serialize the given @Aggregate state and store at the database as a document.
        Parameters:
        aggregate - instance to be created
        Returns:
        the saved aggregate
      • update

        T update​(T aggregate)
        Serialize the given @Aggregate state and update document in the database .
        Parameters:
        aggregate - instance to be store
        Returns:
        the modified aggregate
      • delete

        void delete​(K identifier)
        Delete the @Aggregate with the given identifier.
        Parameters:
        identifier - of the Aggregate
      • count

        Long count​(@Nullable
                   String clause,
                   @Nullable
                   org.springframework.jdbc.core.SqlParameterValue... arguments)
        Returns total registers of a table, matching the given clause and arguments or 0 if none found.
        Parameters:
        clause - can be null.
        arguments - the arguments to be used for lookup, can be null.
        Returns:
        total registers of a table if found any, otherwise 0.