Interface Restriction<X>

Type Parameters:
X - The entity result type of the query

@Incubating public interface Restriction<X>
A rule for restricting query results. This allows restrictions to be added to a QuerySpecification by calling restrict().
 SelectionSpecification.create(Book.class)
         .restrict(Restriction.like(Book_.title, "%Hibernate%", false))
         .restrict(Restriction.greaterThan(Book_.pages, 100))
         .sort(Order.desc(Book_.title))
         .createQuery(session)
         .getResultList();
 

Each restriction pairs an attribute of the entity with a Range of allowed values for the attribute.

A parameter of a finder method or HQL query method may be declared with type Restriction<? super E>, List<Restriction<? super E>>, or Restriction<? super E>... (varargs) where E is the entity type returned by the query.

To create a Restriction on a compound path, use Path.

Since:
7.0
See Also:
API Note:
This class is similar to jakarta.data.Restriction, and is used by Hibernate Data Repositories to implement Jakarta Data query methods.