{"record":{"id":"0475f785dd07a571","repo":"hibernate/hibernate-orm","slug":"not-a-jpacriteriaquery","errorCode":null,"errorMessage":"Not a JpaCriteriaQuery","messagePattern":"Not a JpaCriteriaQuery","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java","lineNumber":101,"sourceCode":"\t */\n\tdefault Restriction<X> and(Restriction<X> restriction) {\n\t\treturn all( this, restriction );\n\t}\n\n\t/**\n\t * Return a JPA Criteria {@link Predicate} constraining the given\n\t * root entity by this restriction.\n\t */\n\t@Internal\n\tPredicate toPredicate(Root<? extends X> root, CriteriaBuilder builder);\n\n\t/**\n\t * Apply this restriction to the given root entity of the given\n\t * {@linkplain CriteriaQuery criteria query}.\n\t */\n\tdefault void apply(CriteriaQuery<?> query, Root<? extends X> root) {\n\t\tif ( !(query instanceof JpaCriteriaQuery<?> criteriaQuery) ) {\n\t\t\tthrow new IllegalArgumentException( \"Not a JpaCriteriaQuery\" );\n\t\t}\n\n\t\tPredicate predicate = toPredicate( root, criteriaQuery.getCriteriaBuilder() );\n\t\tif ( query.getRestriction() == null ) {\n\t\t\tquery.where( predicate );\n\t\t}\n\t\telse {\n\t\t\tquery.where( query.getRestriction(), predicate );\n\t\t}\n\t}\n\n\t/**\n\t * Restrict the allowed values of the given attribute to the given\n\t * {@linkplain Range range}.\n\t */\n\tstatic <T, U> Restriction<T> restrict(SingularAttribute<T, U> attribute, Range<U> range) {\n\t\treturn new AttributeRange<>( attribute, range );\n\t}","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java#L83-L119","documentation":"Error \"Not a JpaCriteriaQuery\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A foreign Criteria API implementation is passed where Hibernate's is required: Not a JpaCriteriaQuery","commonSituations":"Mixing criteria objects from another JPA provider (or plain JPA interfaces) with Hibernate-specific restriction APIs.","solutions":["The criteria query is not a Hibernate JpaCriteriaQuery. Build the criteria through Hibernate's CriteriaBuilder."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}