{"record":{"id":"25555ae2fcc346d7","repo":"hibernate/hibernate-orm","slug":"sqmqualifiedjoin-predicate-referred-to-sqmroot-s","errorCode":null,"errorMessage":"SqmQualifiedJoin predicate referred to SqmRoot [%s] other than the join's root [%s]","messagePattern":"SqmQualifiedJoin predicate referred to SqmRoot \\[(.+?)\\] other than the join's root \\[(.+?)\\]","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/QualifiedJoinPredicatePathConsumer.java","lineNumber":73,"sourceCode":"\t\t\t\t\t\t// If the current processing query contains the root of the current join,\n\t\t\t\t\t\t// then the root of the processing path must be a root of one of the parent queries\n\t\t\t\t\t\tif ( fromClause != null && contains( fromClause.getRoots(), joinRoot ) ) {\n\t\t\t\t\t\t\t// It is allowed to use correlations from the same query\n\t\t\t\t\t\t\tif ( !( root instanceof SqmCorrelation<?, ?> ) || !contains( fromClause.getRoots(), root ) ) {\n\t\t\t\t\t\t\t\tvalidateAsRootOnParentQueryClosure( pathRoot, root,\n\t\t\t\t\t\t\t\t\t\tprocessingState.getParentProcessingState() );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// If the current join is not part of the processing query, this must be a subquery in the ON clause\n\t\t\t\t\t// in which case the path root is allowed to occur in the current processing query as root\n\t\t\t\t\tif ( currentProcessingQuery instanceof SqmSubQuery<?> ) {\n\t\t\t\t\t\tvalidateAsRootOnParentQueryClosure( pathRoot, root, processingState );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new SemanticException(\n\t\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\t\"SqmQualifiedJoin predicate referred to SqmRoot [%s] other than the join's root [%s]\",\n\t\t\t\t\t\t\t\t\tpathRoot.getNavigablePath(),\n\t\t\t\t\t\t\t\t\tsqmJoin.getNavigablePath()\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsuper.validateAsRoot( pathRoot );\n\t\t\t}\n\n\t\t\tprivate void validateAsRootOnParentQueryClosure(\n\t\t\t\t\tSqmFrom<?, ?> pathRoot,\n\t\t\t\t\tSqmRoot<?> root,\n\t\t\t\t\tSqmCreationProcessingState processingState) {\n\t\t\t\twhile ( processingState != null ) {\n\t\t\t\t\tfinal var processingQuery = processingState.getProcessingQuery();","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/QualifiedJoinPredicatePathConsumer.java#L55-L91","documentation":"Error \"SqmQualifiedJoin predicate referred to SqmRoot [%s] other than the join's root [%s]\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A path expression of the wrong type is used in a collection predicate.","commonSituations":"Applying member of / is empty / includes / intersects / in-array to non-plural expressions.","solutions":["Reference only attributes of the join's own root in the ON predicate.","Move cross-root conditions to the WHERE clause."],"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"}