hibernate/hibernate-orm · error · IllegalStateException

There must be at least a single root table assignment

Error message

There must be at least a single root table assignment

What it means

Error "There must be at least a single root table assignment" thrown in hibernate/hibernate-orm.

Source

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

			boolean assignsId,
			String tableExpression,
			String[] keyColumns,
			Map<String, List<Assignment>> assignmentsByTable,
			ExecutionContext executionContext) {
		final var updatingTableReference = updatingTableGroup.getTableReference(
				updatingTableGroup.getNavigablePath(),
				tableExpression,
				true
		);

		final var generator = getEntityDescriptor().getGenerator();
		final var assignments = assignmentsByTable.get( tableExpression );
		if ( !assignsId
			&& ( assignments == null || assignments.isEmpty() )
			&& !generator.generatedOnExecution()
			&& ( !( generator instanceof BulkInsertionCapableIdentifierGenerator bulkInsertionCapable )
					|| bulkInsertionCapable.supportsBulkInsertionIdentifierGeneration() ) ) {
			throw new IllegalStateException( "There must be at least a single root table assignment" );
		}

		final var dmlTableReference = resolveUnionTableReference( updatingTableReference, tableExpression );

		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Create the SQL AST and convert it into a JdbcOperation
		final var querySpec = new QuerySpec( true );
		final var temporaryTableReference = new NamedTableReference(
				translatedInsertStatement.getTargetTable().getTableExpression(),
				"hte_tmp"
		);
		final var temporaryTableGroup = new TableGroupImpl(
				updatingTableGroup.getNavigablePath(),
				null,
				temporaryTableReference,
				getEntityDescriptor()
		);
		querySpec.getFromClause().addRoot( temporaryTableGroup );

View on GitHub (pinned to fad1729dce)

Solutions

  1. The insert/update must assign at least one column of the root table.
  2. Add an assignment that targets the root table, or ensure the id assignment is present.

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/423892ea236a2a51. Report an issue: GitHub.