Interface Specification<T>

All Superinterfaces:
Serializable

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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default Specification<T>
    ANDs the given Specification to the current one.
    static <T> Specification<T>
    not(Specification<T> spec)
    Negates the given Specification.
    default Specification<T>
    or(Specification<T> other)
    ORs the given specification to the current one.
    jakarta.persistence.criteria.Predicate
    toPredicate(jakarta.persistence.criteria.Root<T> root, 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.
    static <T> Specification<T>
    Simple static factory method to add some syntactic sugar around a Specification.
  • 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
    • where

      static <T> Specification<T> where(@Nullable Specification<T> spec)
      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, 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 - must not be null.
      criteriaBuilder - must not be null.
      Returns:
      a Predicate, may be null.