{"record":{"id":"e89e193a0e626765","repo":"hibernate/hibernate-orm","slug":"strict-jpa-query-language-compliance-was-violated-e89e19","errorCode":null,"errorMessage":"Strict JPA query language compliance was violated: use of HQL collection functions (maxelement, minelement, maxindex, minindex, elements, indices)","messagePattern":"Strict JPA query language compliance was violated: use of HQL collection functions \\(maxelement, minelement, maxindex, minindex, elements, indices\\)","errorType":"exception","errorClass":"StrictJpaComplianceViolation","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":5224,"sourceCode":"\t\t}\n\t\telse if ( predicate != null ) {\n\t\t\tif ( getCreationOptions().useStrictJpaCompliance() ) {\n\t\t\t\tthrow new StrictJpaComplianceViolation( StrictJpaComplianceViolation.Type.FUNCTION_CALL );\n\t\t\t}\n\t\t\tfinal var argument = (SqmExpression<?>) predicate.accept( this );\n\t\t\treturn applyOverClause(\n\t\t\t\t\tctx.overClause(),\n\t\t\t\t\tgetFunctionDescriptor( \"every\" ).generateAggregateSqmExpression(\n\t\t\t\t\t\t\tsingletonList( argument ),\n\t\t\t\t\t\t\tgetFilterExpression( ctx ),\n\t\t\t\t\t\t\tnodeBuilder().getBooleanType(),\n\t\t\t\t\t\t\tqueryEngine()\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\telse {\n\t\t\tif ( getCreationOptions().useStrictJpaCompliance() ) {\n\t\t\t\tthrow new StrictJpaComplianceViolation( StrictJpaComplianceViolation.Type.HQL_COLLECTION_FUNCTION );\n\t\t\t}\n\t\t\treturn new SqmEvery<>(\n\t\t\t\t\tcreateCollectionReferenceSubQuery(\n\t\t\t\t\t\t\tctx.simplePath(),\n\t\t\t\t\t\t\t(TerminalNode) ctx.collectionQuantifier().getChild(0).getChild(0)\n\t\t\t\t\t),\n\t\t\t\t\tnodeBuilder()\n\t\t\t);\n\t\t}\n\t}\n\n\t@Override\n\tpublic SqmExpression<?> visitAnyFunction(HqlParser.AnyFunctionContext ctx) {\n\t\tif ( ctx.subquery() != null ) {\n\t\t\tfinal var subquery = (SqmSubQuery<?>) ctx.subquery().accept( this );\n\t\t\treturn new SqmAny<>( subquery, nodeBuilder() );\n\t\t}\n\t\telse if ( ctx.predicate() != null ) {","sourceCodeStart":5206,"sourceCodeEnd":5242,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L5206-L5242","documentation":"Error \"Strict JPA query language compliance was violated: use of HQL collection functions (maxelement, minelement, maxindex, minindex, elements, indices)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An HQL-specific construct is used while strict JPQL compliance is enabled: Strict JPA query language compliance was violated: use of HQL collection functions (maxelement, minelement, maxindex, minindex, elements, indices)","commonSituations":"Applications running with hibernate.jpa.compliance.query=true (or JPA-compliance mode) that submit queries using Hibernate extensions such as collations, tuples/row value constructors, HQL collection functions (maxelement/elements/indices), value()/key() on non-Map types, or non-standard function calls without FUNCTION() syntax.","solutions":["HQL collection functions (maxelement, minelement, maxindex, minindex, elements, indices) are not JPA-standard. Rewrite using joins/subqueries, or relax strict JPA compliance."],"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"}