hibernate/hibernate-orm · error · IllegalArgumentException
Not a JpaCriteriaQuery
Error message
Not a JpaCriteriaQuery
What it means
Error "Not a JpaCriteriaQuery" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java:101
*/
default Restriction<X> and(Restriction<X> restriction) {
return all( this, restriction );
}
/**
* Return a JPA Criteria {@link Predicate} constraining the given
* root entity by this restriction.
*/
@Internal
Predicate toPredicate(Root<? extends X> root, CriteriaBuilder builder);
/**
* Apply this restriction to the given root entity of the given
* {@linkplain CriteriaQuery criteria query}.
*/
default void apply(CriteriaQuery<?> query, Root<? extends X> root) {
if ( !(query instanceof JpaCriteriaQuery<?> criteriaQuery) ) {
throw new IllegalArgumentException( "Not a JpaCriteriaQuery" );
}
Predicate predicate = toPredicate( root, criteriaQuery.getCriteriaBuilder() );
if ( query.getRestriction() == null ) {
query.where( predicate );
}
else {
query.where( query.getRestriction(), predicate );
}
}
/**
* Restrict the allowed values of the given attribute to the given
* {@linkplain Range range}.
*/
static <T, U> Restriction<T> restrict(SingularAttribute<T, U> attribute, Range<U> range) {
return new AttributeRange<>( attribute, range );
}View on GitHub (pinned to fad1729dce)
Solutions
- The criteria query is not a Hibernate JpaCriteriaQuery. Build the criteria through Hibernate's CriteriaBuilder.
When it happens
Trigger: A foreign Criteria API implementation is passed where Hibernate's is required: Not a JpaCriteriaQuery
Common situations: Mixing criteria objects from another JPA provider (or plain JPA interfaces) with Hibernate-specific restriction APIs.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/0475f785dd07a571.
Report an issue: GitHub.