hibernate/hibernate-orm · error · SemanticException

SqmQualifiedJoin predicate referred to SqmRoot

Error message

SqmQualifiedJoin predicate referred to SqmRoot [%s] other than the join's root [%s]

What it means

Thrown by QualifiedJoinPredicatePathConsumer.validateAsRoot when the SqmRoot referenced by a join predicate's path belongs to a different query than the join's own root (and is not a legal correlation from the current or a parent query). It guards against cross-query references in 'on' clauses; the offending inputs are the predicate's path root and the join's root, reported via String.format.

Solutions

  1. Reference only attributes of the join's own root in the ON predicate.
  2. Move cross-root conditions to the WHERE clause.
Defensive patterns

Strategy: validation

When it happens

Trigger: A path expression of the wrong type is used in a collection predicate.

Common situations: Applying member of / is empty / includes / intersects / in-array to non-plural expressions.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/25555ae2fcc346d7. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/QualifiedJoinPredicatePathConsumer.java:73

						// If the current processing query contains the root of the current join,
						// then the root of the processing path must be a root of one of the parent queries
						if ( fromClause != null && contains( fromClause.getRoots(), joinRoot ) ) {
							// It is allowed to use correlations from the same query
							if ( !( root instanceof SqmCorrelation<?, ?> ) || !contains( fromClause.getRoots(), root ) ) {
								validateAsRootOnParentQueryClosure( pathRoot, root,
										processingState.getParentProcessingState() );
							}
							return;
						}
					}
					// If the current join is not part of the processing query, this must be a subquery in the ON clause
					// in which case the path root is allowed to occur in the current processing query as root
					if ( currentProcessingQuery instanceof SqmSubQuery<?> ) {
						validateAsRootOnParentQueryClosure( pathRoot, root, processingState );
						return;
					}

					throw new SemanticException(
							String.format(
									Locale.ROOT,
									"SqmQualifiedJoin predicate referred to SqmRoot [%s] other than the join's root [%s]",
									pathRoot.getNavigablePath(),
									sqmJoin.getNavigablePath()
							)
					);
				}

				super.validateAsRoot( pathRoot );
			}

			private void validateAsRootOnParentQueryClosure(
					SqmFrom<?, ?> pathRoot,
					SqmRoot<?> root,
					SqmCreationProcessingState processingState) {
				while ( processingState != null ) {
					final var processingQuery = processingState.getProcessingQuery();

View on GitHub (pinned to fad1729dce)