hibernate/hibernate-orm · error · StrictJpaComplianceViolation

Encountered implicit 'from' clause, but strict JPQL complian

Error message

Encountered implicit 'from' clause, but strict JPQL compliance was requested

What it means

Error "Encountered implicit 'from' clause, but strict JPQL compliance was requested" thrown in hibernate/hibernate-orm.

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)

Solutions

  1. Add an explicit 'from' clause to the query.
  2. Disable strict JPQL compliance if implicit from is intended.

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.