hibernate/hibernate-orm · error · StrictJpaComplianceViolation

COLLATIONS

COLLATIONS

Error message

Strict JPA query language compliance was violated: use of collations

What it means

Raised as StrictJpaComplianceViolation (type COLLATIONS) from SemanticQueryBuilder.visitCollateFunction when the query uses the 'collate()' expression while strict JPA query language compliance is enabled. Collation control is an HQL extension outside the JPQL grammar, hence rejected in strict mode.

Solutions

  1. Strict JPA compliance forbids collations in the query. Remove the collation usage, or disable strict JPA compliance (hibernate.jpa.compliance / JpaComplianceViolation) if HQL extensions are intended.
Defensive patterns

Strategy: validation

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 collations

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/1cd37f82b256b686. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:3825

	}

	@Override
	public SqmUnaryOperation<?> visitUnaryExpression(HqlParser.UnaryExpressionContext ctx) {
		final var expression = (SqmExpression<?>) ctx.expression().accept(this);
		final UnaryArithmeticOperator operator = (UnaryArithmeticOperator) ctx.signOperator().accept(this);
		TypecheckUtil.assertNumeric( expression, operator );
		return new SqmUnaryOperation<>( operator, expression, nodeBuilder() );
	}

	@Override
	public Object visitGroupedExpression(HqlParser.GroupedExpressionContext ctx) {
		return ctx.getChild( 1 ).accept( this );
	}

	@Override
	public Object visitCollateFunction(HqlParser.CollateFunctionContext ctx) {
		if ( creationOptions.useStrictJpaCompliance() ) {
			throw new StrictJpaComplianceViolation(
					StrictJpaComplianceViolation.Type.COLLATIONS
			);
		}

		final var expressionToCollate = (SqmExpression<?>) ctx.expression().accept( this );
		final SqmCollation castTargetExpression = (SqmCollation) ctx.collation().accept( this );

		return getFunctionDescriptor("collate").generateSqmExpression(
				asList( expressionToCollate, castTargetExpression ),
				null, //why not string?
				queryEngine()
		);
	}

	@Override
	public Object visitCollation(HqlParser.CollationContext ctx) {
		final var collation = new StringBuilder();
		final var simplePathContext = ctx.simplePath();

View on GitHub (pinned to fad1729dce)