hibernate/hibernate-orm · error · IllegalStateException

Attempting to get a result list from a mutation query

Error message

Attempting to get a result list from a mutation query

What it means

Error "Attempting to get a result list from a mutation query" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/MutationQueryImpl.java:397

		}

		return false;
	}

	protected boolean isSimpleValuesInsert(SqmInsertStatement<?> sqmInsert, EntityPersister entityDescriptor) {
		// Simple means that we can translate the statement to a single plain insert
		return sqmInsert instanceof SqmInsertValuesStatement
			// An insert is only simple if no SqmMultiTableMutation strategy is available,
			// as the presence of it means the entity has multiple tables involved,
			// in which case we currently need to use the MultiTableInsertQueryPlan
			&& entityDescriptor.getSqmMultiTableMutationStrategy() == null;
	}

	@Override @SuppressWarnings("deprecation")
	@Nonnull
	public List<T> getResultList() {
		final var message = "Attempting to get a result list from a mutation query";
		throw new IllegalStateException( message, new IllegalSelectQueryException( message, hql ) );
	}

	@Override @SuppressWarnings("deprecation")
	@Nonnull
	public ScrollableResults<T> scroll(@Nonnull ScrollMode scrollMode) {
		final var message = "Attempting to scroll list from a mutation query";
		throw new IllegalStateException( message, new IllegalSelectQueryException( message, hql ) );
	}


	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Options

	@Override
	protected void verifySelectionOption(String name) {
		throw selectionOption( name );
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Mutation queries do not produce result lists. Use executeUpdate() for update/delete/insert statements.

When it happens

Trigger: A selection-only operation is invoked on a mutation (insert/update/delete) query: Attempting to get a result list from a mutation query

Common situations: Calling getResultList()/scroll()/unwrap(SelectionQuery) on a Query created from an update/delete/insert HQL statement, or vice versa.


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