hibernate/hibernate-orm · error · StrictJpaComplianceViolation
Strict JPA query language compliance was violated: use of HQ
Error message
Strict JPA query language compliance was violated: use of HQL collection functions (maxelement, minelement, maxindex, minindex, elements, indices)
What it means
Error "Strict JPA query language compliance was violated: use of HQL collection functions (maxelement, minelement, maxindex, minindex, elements, indices)" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:5224
}
else if ( predicate != null ) {
if ( getCreationOptions().useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation( StrictJpaComplianceViolation.Type.FUNCTION_CALL );
}
final var argument = (SqmExpression<?>) predicate.accept( this );
return applyOverClause(
ctx.overClause(),
getFunctionDescriptor( "every" ).generateAggregateSqmExpression(
singletonList( argument ),
getFilterExpression( ctx ),
nodeBuilder().getBooleanType(),
queryEngine()
)
);
}
else {
if ( getCreationOptions().useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation( StrictJpaComplianceViolation.Type.HQL_COLLECTION_FUNCTION );
}
return new SqmEvery<>(
createCollectionReferenceSubQuery(
ctx.simplePath(),
(TerminalNode) ctx.collectionQuantifier().getChild(0).getChild(0)
),
nodeBuilder()
);
}
}
@Override
public SqmExpression<?> visitAnyFunction(HqlParser.AnyFunctionContext ctx) {
if ( ctx.subquery() != null ) {
final var subquery = (SqmSubQuery<?>) ctx.subquery().accept( this );
return new SqmAny<>( subquery, nodeBuilder() );
}
else if ( ctx.predicate() != null ) {View on GitHub (pinned to fad1729dce)
Solutions
- HQL collection functions (maxelement, minelement, maxindex, minindex, elements, indices) are not JPA-standard. Rewrite using joins/subqueries, or relax strict JPA compliance.
When it happens
Trigger: 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)
Common situations: 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.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/e89e193a0e626765.
Report an issue: GitHub.