hibernate/hibernate-orm · error · UnsupportedOperationException

ProcedureCall cannot be treated as a mutation query

Error message

ProcedureCall cannot be treated as a mutation query

What it means

Error "ProcedureCall cannot be treated as a mutation query" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/procedure/internal/NamedCallableQueryMementoImpl.java:158

		return new ProcedureCallImpl<>( session, this, resultSetMappingNames );
	}

	@Nonnull
	@Override
	public ProcedureCallImplementor toQuery(@Nonnull SharedSessionContractImplementor session) {
		return makeProcedureCall( session );
	}

	@Nonnull
	@Override
	public <T> ProcedureCallImplementor<T> toQuery(@Nonnull SharedSessionContractImplementor session, @Nullable Class<T> javaType) {
		return makeProcedureCall( session );
	}

	@Nonnull
	@Override
	public MutationQueryImplementor<Object> toMutationQuery(@Nonnull SharedSessionContractImplementor session) {
		throw new UnsupportedOperationException( "ProcedureCall cannot be treated as a mutation query" );
	}

	@Nonnull
	@Override
	public <T> MutationQueryImplementor<T> toMutationQuery(@Nonnull SharedSessionContractImplementor session, @Nullable Class<T> targetType) {
		throw new UnsupportedOperationException( "ProcedureCall cannot be treated as a mutation query" );
	}

	@Nonnull
	@Override
	public SelectionQueryImplementor<Object> toSelectionQuery(@Nonnull SharedSessionContractImplementor session) {
		throw new UnsupportedOperationException( "ProcedureCall cannot be treated as a selection query" );
	}

	@Nonnull
	@Override
	public <T> SelectionQueryImplementor<T> toSelectionQuery(@Nonnull SharedSessionContractImplementor session, @Nullable Class<T> javaType) {
		throw new UnsupportedOperationException( "ProcedureCall cannot be treated as a selection query" );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Do not cast a ProcedureCall to MutationQuery; use execute()/getOutputs() on the ProcedureCall API.
  2. If a mutation is needed, use a HQL update statement instead of a procedure call.

When it happens

Trigger: An API operation is invoked on an object that does not support it.

Common situations: Using query/procedure/proxy APIs beyond their supported feature set (e.g. scrolling, locking, unwrapping a procedure call).


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