Interface Specification<T>

All Superinterfaces:
Serializable
All Known Implementing Classes:
KeysetScrollSpecification
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Specification<T> extends Serializable
Specification in the sense of Domain Driven Design.
Author:
Oliver Gierke, Thomas Darimont, Krzysztof Rzymkowski, Sebastian Staudt, Mark Paluch, Jens Schauder, Daniel Shuy, Sergey Rukin
  • Field Details

  • Method Details

    • not

      static <T> Specification<T> not(@Nullable Specification<T> spec)
      Negates the given Specification.
      Type Parameters:
      T - the type of the Root the resulting Specification operates on.
      Parameters:
      spec - can be null.
      Returns:
      guaranteed to be not null.
      Since:
      2.0
    • unrestricted

      static <T> Specification<T> unrestricted()
      Simple static factory method to create a specification matching all objects.
      Type Parameters:
      T - the type of the Root the resulting Specification operates on.
      Returns:
      guaranteed to be not null.
      Since:
      3.5.2
    • where

      @Deprecated(since="3.5.0", forRemoval=true) static <T> Specification<T> where(@Nullable Specification<T> spec)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 3.5, to be removed with 4.0 as we no longer want to support null specifications. Use unrestricted() instead.
      Simple static factory method to add some syntactic sugar around a Specification.
      Type Parameters:
      T - the type of the Root the resulting Specification operates on.
      Parameters:
      spec - can be null.
      Returns:
      guaranteed to be not null.
      Since:
      2.0
    • and

      default Specification<T> and(@Nullable Specification<T> other)
      ANDs the given Specification to the current one.
      Parameters:
      other - can be null.
      Returns:
      The conjunction of the specifications
      Since:
      2.0
    • or

      default Specification<T> or(@Nullable Specification<T> other)
      ORs the given specification to the current one.
      Parameters:
      other - can be null.
      Returns:
      The disjunction of the specifications
      Since:
      2.0
    • toPredicate

      @Nullable jakarta.persistence.criteria.Predicate toPredicate(jakarta.persistence.criteria.Root<T> root, @Nullable jakarta.persistence.criteria.CriteriaQuery<?> query, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder)
      Creates a WHERE clause for a query of the referenced entity in form of a Predicate for the given Root and CriteriaQuery.
      Parameters:
      root - must not be null.
      query - can be null to allow overrides that accept CriteriaDelete which is an AbstractQuery but no CriteriaQuery.
      criteriaBuilder - must not be null.
      Returns:
      a Predicate, may be null.
    • allOf

      static <T> Specification<T> allOf(Iterable<Specification<T>> specifications)
      Applies an AND operation to all the given Specifications.
      Parameters:
      specifications - The Specifications to compose. Can contain nulls.
      Returns:
      The conjunction of the specifications
      Since:
      3.0
      See Also:
    • allOf

      @SafeVarargs static <T> Specification<T> allOf(Specification<T>... specifications)
      Since:
      3.0
      See Also:
    • anyOf

      static <T> Specification<T> anyOf(Iterable<Specification<T>> specifications)
      Applies an OR operation to all the given Specifications.
      Parameters:
      specifications - The Specifications to compose. Can contain nulls.
      Returns:
      The disjunction of the specifications
      Since:
      3.0
      See Also:
    • anyOf

      @SafeVarargs static <T> Specification<T> anyOf(Specification<T>... specifications)
      Since:
      3.0
      See Also: