hibernate/hibernate-orm · error · StrictJpaComplianceViolation
Strict JPA query language compliance was violated: use of CT
Error message
Strict JPA query language compliance was violated: use of CTEs (common table expressions)
What it means
Error "Strict JPA query language compliance was violated: use of CTEs (common table expressions)" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:770
if ( whereClauseContext != null ) {
deleteStatement.applyPredicate( visitWhereClause( whereClauseContext ) );
}
return deleteStatement;
}
finally {
processingStateStack.pop();
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Query spec
@Override
public Object visitWithClause(HqlParser.WithClauseContext ctx) {
if ( creationOptions.useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation(
StrictJpaComplianceViolation.Type.CTES
);
}
final List<ParseTree> children = ctx.children;
for ( int i = 1; i < children.size(); i += 2 ) {
visitCte( (HqlParser.CteContext) children.get( i ) );
}
return null;
}
@Override
public Object visitCte(HqlParser.CteContext ctx) {
final var cteContainer = (SqmCteContainer) processingStateStack.getCurrent().getProcessingQuery();
final String name = visitIdentifier( ctx.identifier() );
final var thirdChild = (TerminalNode) ctx.getChild( 2 );
final var materialization = switch ( thirdChild.getSymbol().getType() ) {
case HqlParser.NOT -> CteMaterialization.NOT_MATERIALIZED;
case HqlParser.MATERIALIZED -> CteMaterialization.MATERIALIZED;View on GitHub (pinned to fad1729dce)
Solutions
- Disable strict JPA compliance (hibernate.jpa.compliance.query=false) to use CTEs.
- Rewrite the query without common table expressions.
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/23a4d352e474051f.
Report an issue: GitHub.