hibernate/hibernate-orm · error · SemanticException
Cannot join to root entity '" + identifier + "'
Error message
Cannot join to root entity '" + identifier + "'
What it means
Error "Cannot join to root entity '" + identifier + "'" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/QualifiedJoinPathConsumer.java:175
identifier,
joinType,
alias,
fetch,
isTerminal,
true,
creationState
),
joinType,
fetch,
alias,
creationState
);
}
private AttributeJoinDelegate resolveAlias(String identifier, boolean isTerminal, SqmFrom<?, Object> pathRootByAlias) {
// identifier is an alias (identification variable)
if (isTerminal) {
throw new SemanticException( "Cannot join to root entity '" + identifier + "'" );
}
else {
return new AttributeJoinDelegate(
pathRootByAlias,
joinType,
fetch,
alias,
creationState
);
}
}
private static <U> SqmFrom<?, ?> createJoin(
SqmFrom<?, U> lhs,
String name,
SqmJoinType joinType,
String alias,
boolean fetch,View on GitHub (pinned to fad1729dce)
Solutions
- Join through an association path (e.g. root.children) rather than the root entity name.
- Declare the entity in the from clause instead of joining to it.
When it happens
Trigger: A runtime precondition of the Hibernate API is violated.
Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/acf76f43d4ead8f8.
Report an issue: GitHub.