{"record":{"id":"21b4be859394e80b","repo":"hibernate/hibernate-orm","slug":"strict-jpa-query-language-compliance-was-violated-21b4be","errorCode":null,"errorMessage":"Strict JPA query language compliance was violated: use of LIMIT/OFFSET clause","messagePattern":"Strict JPA query language compliance was violated: use of LIMIT/OFFSET clause","errorType":"exception","errorClass":"StrictJpaComplianceViolation","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":1134,"sourceCode":"\tpublic SetOperator visitSetOperator(HqlParser.SetOperatorContext ctx) {\n\t\tfinal var token = ( (TerminalNode) ctx.getChild( 0 ) ).getSymbol();\n\t\tfinal boolean all = ctx.getChildCount() == 2;\n\t\treturn switch ( token.getType() ) {\n\t\t\tcase UNION -> all ? SetOperator.UNION_ALL : SetOperator.UNION;\n\t\t\tcase INTERSECT -> all ? SetOperator.INTERSECT_ALL : SetOperator.INTERSECT;\n\t\t\tcase EXCEPT -> all ? SetOperator.EXCEPT_ALL : SetOperator.EXCEPT;\n\t\t\tdefault -> throw new ParsingException( \"Unrecognized set operator: \" + token.getText() );\n\t\t};\n\t}\n\n\tprotected void visitLimitOffset(SqmQueryPart<?> sqmQueryPart, HqlParser.LimitOffsetContext ctx) {\n\t\tif ( ctx != null ) {\n\t\t\tfinal var limitClauseContext = ctx.limitClause();\n\t\t\tfinal var offsetClauseContext = ctx.offsetClause();\n\t\t\tfinal var fetchClauseContext = ctx.fetchClause();\n\t\t\tif ( limitClauseContext != null || offsetClauseContext != null || fetchClauseContext != null ) {\n\t\t\t\tif ( getCreationOptions().useStrictJpaCompliance() ) {\n\t\t\t\t\tthrow new StrictJpaComplianceViolation(\n\t\t\t\t\t\t\tStrictJpaComplianceViolation.Type.LIMIT_OFFSET_CLAUSE\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( processingStateStack.depth() > 1 && sqmQueryPart.getOrderByClause() == null ) {\n\t\t\t\t\tthrow new SemanticException(\n\t\t\t\t\t\t\t\"A 'limit', 'offset', or 'fetch' clause requires an 'order by' clause when used in a subquery\",\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsetOffsetFetchLimit( sqmQueryPart, limitClauseContext, offsetClauseContext, fetchClauseContext );\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected void visitOrderBy(SqmQueryPart<?> sqmQueryPart, HqlParser.OrderByClauseContext ctx) {\n\t\tif ( ctx != null ) {","sourceCodeStart":1116,"sourceCodeEnd":1152,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L1116-L1152","documentation":"Error \"Strict JPA query language compliance was violated: use of LIMIT/OFFSET clause\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An HQL extension is used while strict JPQL compliance is enabled.","commonSituations":"Running HQL-specific syntax (CTEs, limit/offset, collection functions) with hibernate.jpa.compliance.query=true.","solutions":["Disable strict JPA compliance to use limit/offset in HQL.","Use setMaxResults/setFirstResult instead of LIMIT/OFFSET syntax."],"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"}