hibernate/hibernate-orm · error · StrictJpaComplianceViolation
HQL_COLLECTION_FUNCTION
HQL_COLLECTION_FUNCTION
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:1489
if ( expressionOrPredicate.expression()
instanceof HqlParser.BarePrimaryExpressionContext barePrimaryExpression
&& barePrimaryExpression.primaryExpression()
instanceof HqlParser.FunctionExpressionContext functionExpression
&& functionExpression.pathContinuation() == null
&& functionExpression.slicedPathAccessFragment() == null
&& functionExpression.indexedPathAccessFragment() == null ) {
final var collectionFunctionMisuse = functionExpression.function().collectionFunctionMisuse();
if ( collectionFunctionMisuse != null ) {
return visitCollectionFunctionSelection( collectionFunctionMisuse );
}
}
return null;
}
private SqmPluralPartSelectionPath<?> visitCollectionFunctionSelection(
HqlParser.CollectionFunctionMisuseContext ctx) {
if ( getCreationOptions().useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation( StrictJpaComplianceViolation.Type.HQL_COLLECTION_FUNCTION );
}
final var pluralAttributePath = consumeDomainPath( ctx.path() );
final var firstNode = (TerminalNode) ctx.getChild( 0 ).getChild( 0 );
if ( !( pluralAttributePath.getReferencedPathSource() instanceof PluralPersistentAttribute<?, ?, ?> ) ) {
throw new FunctionArgumentException(
String.format(
"Argument '%s' of '%s()' function is not a plural path ",
pluralAttributePath.getNavigablePath(),
firstNode.getSymbol().getText()
)
);
}
return new SqmPluralPartSelectionPath<>(
(SqmPluralValuedSimplePath<?>) pluralAttributePath,
collectionFunctionNature( firstNode )View on GitHub (pinned to fad1729dce)
Solutions
- Disable strict JPA compliance to use HQL collection functions.
- Rewrite using standard JPA constructs (joins/subqueries).
When it happens
Trigger: An HQL extension is used while strict JPQL compliance is enabled.
Common situations: Running HQL-specific syntax (CTEs, limit/offset, collection functions) with hibernate.jpa.compliance.query=true.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/32adea44e2a742fe.
Report an issue: GitHub.