hibernate/hibernate-orm · error · IllegalMutationQueryException

Expecting a delete or update query, but found '{}'

Error message

Expecting a delete or update query, but found '{}'

What it means

Error "Expecting a delete or update query, but found '{}'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/specification/internal/MutationSpecificationImpl.java:303

	 * and produce the corresponding SQM tree.
	 */
	@Nonnull
	private static <T> SqmDeleteOrUpdateStatement<T> resolveSqmTree(
			@Nonnull String hql,
			@Nonnull QueryEngine queryEngine) {
		final HqlInterpretation<T> hqlInterpretation =
				queryEngine.getInterpretationCache()
						// FIXME : unchecked cast
						.resolveHqlInterpretation( hql, null, queryEngine.getHqlTranslator() );
		if ( SqmUtil.isRestrictedMutation( hqlInterpretation.getSqmStatement() ) ) {
			// NOTE: this copy is to isolate the actual AST tree from the
			// one stored in the interpretation cache
			return (SqmDeleteOrUpdateStatement<T>)
					hqlInterpretation.getSqmStatement()
							.copy( noParamCopyContext( SqmQuerySource.CRITERIA ) );
		}
		else {
			throw new IllegalMutationQueryException( "Expecting a delete or update query, but found '" + hql + "'",
					hql );
		}
	}

	/**
	 * Used during construction to resolve an incoming named statement reference
	 * and produce the corresponding SQM tree.
	 */
	@Nonnull
	private static <T> SqmDeleteOrUpdateStatement<T> resolveSqmTree(
			@Nonnull NamedSqmQueryMemento<?> sqmMemento,
			@Nonnull QueryEngine queryEngine) {
		final var sqmStatement = sqmMemento.getSqmStatement();
		if ( sqmStatement == null ) {
			return resolveSqmTree( sqmMemento.getHqlString(), queryEngine );
		}
		else if ( SqmUtil.isRestrictedMutation( sqmStatement ) ) {
			//noinspection unchecked

View on GitHub (pinned to fad1729dce)

Solutions

  1. A mutation specification requires a delete or update query. Supply an HQL/criteria delete or update statement.

When it happens

Trigger: A Specification is given a statement of the wrong kind: Expecting a delete or update query, but found '<value>'

Common situations: Passing a select statement to MutationSpecification or a mutation statement to SelectionSpecification.


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