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
Error "The 'from' clause of a set returning function has a 'fetch' join" thrown in hibernate/hibernate-orm.
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)
Solutions
- Remove the fetch join from the set-returning function's from clause.
- Fetch the association in the outer query instead.
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.