hibernate/hibernate-orm · error · SemanticException

Assignment referred to columns from multiple tables: ${i}

Error message

Assignment referred to columns from multiple tables: ${i}

What it means

Error "Assignment referred to columns from multiple tables: ${i}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/TableBasedInsertHandler.java:374

			);
		}


		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// segment the assignments by table-reference

		for ( int i = 0; i < targetPathColumns.size(); i++ ) {
			final var assignment = targetPathColumns.get( i );
			final var assignable = assignment.getAssignable();
			final var assignmentColumnRefs = assignable.getColumnReferences();

			TableReference assignmentTableReference = null;
			for ( int c = 0; c < assignmentColumnRefs.size(); c++ ) {
				final var columnReference = assignmentColumnRefs.get( c );
				final var tableReference = resolveTableReference( columnReference, tableReferenceByAlias );

				if ( assignmentTableReference != null && assignmentTableReference != tableReference ) {
					throw new SemanticException( "Assignment referred to columns from multiple tables: " + i );
				}
				assignmentTableReference = tableReference;
			}

			assignmentsByTable.computeIfAbsent(
					assignmentTableReference == null
							? null
							: assignmentTableReference.getTableId(),
					k -> new ArrayList<>() ).add( assignment );
		}

		this.temporaryTableInsert =
				createTemporaryTableInsert(
						insertStatement,
						jdbcParameterBindings,
						executionContext
				);

View on GitHub (pinned to fad1729dce)

Solutions

  1. An INSERT assignment referred to columns from multiple tables.
  2. Restrict each insert's assignments to columns of a single table, or split into multiple inserts.

When it happens

Trigger: An UPDATE/INSERT assignment targets columns that cannot be handled by the mutation strategy.

Common situations: Bulk HQL update/insert statements assigning columns spread across multiple tables or columns of joined associations.


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