{"record":{"id":"acf76f43d4ead8f8","repo":"hibernate/hibernate-orm","slug":"cannot-join-to-root-entity-identifier","errorCode":null,"errorMessage":"Cannot join to root entity '\" + identifier + \"'","messagePattern":"Cannot join to root entity '\" \\+ identifier \\+ \"'","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/QualifiedJoinPathConsumer.java","lineNumber":175,"sourceCode":"\t\t\t\t\t\tidentifier,\n\t\t\t\t\t\tjoinType,\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tfetch,\n\t\t\t\t\t\tisTerminal,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tcreationState\n\t\t\t\t),\n\t\t\t\tjoinType,\n\t\t\t\tfetch,\n\t\t\t\talias,\n\t\t\t\tcreationState\n\t\t);\n\t}\n\n\tprivate AttributeJoinDelegate resolveAlias(String identifier, boolean isTerminal, SqmFrom<?, Object> pathRootByAlias) {\n\t\t// identifier is an alias (identification variable)\n\t\tif (isTerminal) {\n\t\t\tthrow new SemanticException( \"Cannot join to root entity '\" + identifier + \"'\" );\n\t\t}\n\t\telse {\n\t\t\treturn new AttributeJoinDelegate(\n\t\t\t\t\tpathRootByAlias,\n\t\t\t\t\tjoinType,\n\t\t\t\t\tfetch,\n\t\t\t\t\talias,\n\t\t\t\t\tcreationState\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate static <U> SqmFrom<?, ?> createJoin(\n\t\t\tSqmFrom<?, U> lhs,\n\t\t\tString name,\n\t\t\tSqmJoinType joinType,\n\t\t\tString alias,\n\t\t\tboolean fetch,","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/QualifiedJoinPathConsumer.java#L157-L193","documentation":"Error \"Cannot join to root entity '\" + identifier + \"'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}