hibernate/hibernate-orm · error · StrictJpaComplianceViolation
Encountered implicit 'from' clause, but strict JPQL…
Error message
Encountered implicit 'from' clause, but strict JPQL compliance was requested
What it means
Thrown by SemanticQueryBuilder.buildInferredFromClause when Hibernate would have to infer the 'from' clause from the select list, but strict JPQL compliance was requested. Implicit 'from' inference is an HQL convenience extension; in strict JPQL mode the query must state its 'from' clause explicitly, hence the StrictJpaComplianceViolation.
Solutions
- Add an explicit 'from' clause to the query.
- Disable strict JPQL compliance if implicit from is intended.
Defensive patterns
Strategy: validation
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/30f02879b502a5d0.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:1230
if ( groupByClauseContext != null ) {
sqmQuerySpec.setGroupByClauseExpressions( visitGroupByClause( groupByClauseContext ) );
}
if ( havingClauseContext != null ) {
sqmQuerySpec.setHavingClausePredicate( visitHavingClause( havingClauseContext ) );
}
return sqmQuerySpec;
}
private SqmFromClause buildInferredFromClause(HqlParser.SelectClauseContext selectClauseContext) {
if ( selectClauseContext != null || processingStateStack.depth() > 1 ) {
// when there's an explicit 'select', or in a subquery, we never infer the 'from'
return new SqmFromClause();
}
else {
if ( creationOptions.useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation(
"Encountered implicit 'from' clause, but strict JPQL compliance was requested",
StrictJpaComplianceViolation.Type.IMPLICIT_FROM
);
}
final var fromClause = new SqmFromClause();
final var entityDescriptor = getResultEntity();
if ( entityDescriptor != null ) {
final SqmRoot<R> sqmRoot =
new SqmRoot<>( entityDescriptor, "_0", false, nodeBuilder() );
processingStateStack.getCurrent().getPathRegistry().register( sqmRoot );
fromClause.addRoot( sqmRoot );
}
return fromClause;
}
}
private EntityDomainType<R> getResultEntity() {View on GitHub (pinned to fad1729dce)