hibernate/hibernate-orm · error · SemanticException
The 'from' clause of a set returning function has a 'fetch'…
Error message
The 'from' clause of a set returning function has a 'fetch' join
What it means
Thrown while parsing a lateral/system set-returning-function subquery join in SemanticQueryBuilder: the inferred 'from' clause of the set-returning function's subquery contains a 'fetch' join. Fetch joining inside a table function's from clause is not supported by Hibernate's SQM model, so the unsupported shape raises a SemanticException naming the offending join.
Solutions
- Remove the fetch join from the set-returning function's from clause.
- Fetch the association in the outer query instead.
Defensive patterns
Strategy: validation
When it happens
Trigger: The HQL/JPQL query violates a structural language rule.
Common situations: Writing queries with missing select/from, mismatched group by positions, or invalid ordering constructs.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/5a1e19dd33084296.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:2375
if ( getCreationOptions().useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation(
"The JPA specification does not support subqueries in the from clause. " +
"Please disable the JPA query compliance if you want to use this feature.",
StrictJpaComplianceViolation.Type.FROM_SUBQUERY
);
}
final boolean lateral = joinSubqueryContext.LATERAL() != null;
final var identifierConsumer = dotIdentifierConsumerStack.pop();
final var subQuery = (SqmSubQuery<X>) joinSubqueryContext.subquery().accept( this );
dotIdentifierConsumerStack.push( identifierConsumer );
final var join = new SqmDerivedJoin<>( subQuery, alias, joinType, lateral, sqmRoot );
processingStateStack.getCurrent().getPathRegistry().register( join );
return join;
}
else if ( joinTargetContext instanceof HqlParser.JoinFunctionContext joinFunctionContext ) {
if ( fetch ) {
throw new SemanticException( "The 'from' clause of a set returning function has a 'fetch' join", query );
}
if ( getCreationOptions().useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation(
"The JPA specification does not support functions in the from clause. " +
"Please disable the JPA query compliance if you want to use this feature.",
StrictJpaComplianceViolation.Type.FROM_FUNCTION
);
}
final boolean lateral = joinFunctionContext.LATERAL() != null;
final var identifierConsumer = dotIdentifierConsumerStack.pop();
final var function = (SqmSetReturningFunction<?>) joinFunctionContext.setReturningFunction().accept( this );
dotIdentifierConsumerStack.push( identifierConsumer );
final var join = new SqmFunctionJoin<>(
function,
alias,
joinType,
lateral,View on GitHub (pinned to fad1729dce)