hibernate/hibernate-orm · error · IllegalOutputTypeException

Cannot treat UpdateCountOutput as ResultSetOutput

Error message

Cannot treat UpdateCountOutput as ResultSetOutput

What it means

Error "Cannot treat UpdateCountOutput as ResultSetOutput" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/procedure/UpdateCountOutput.java:23

package org.hibernate.procedure;

import jakarta.persistence.sql.ResultSetMapping;

/// Models a return that is an update count (count of rows affected)
///
/// @author Steve Ebersole
public interface UpdateCountOutput extends Output {
	/// Retrieve the associated update count
	int getUpdateCount();

	@Override
	default UpdateCountOutput asUpdateCountOutput() {
		return this;
	}

	@Override
	default ResultSetOutput<?> asResultSetOutput() {
		throw new  IllegalOutputTypeException( "Cannot treat UpdateCountOutput as ResultSetOutput" );
	}

	@Override
	default <X> ResultSetOutput<X> asResultSetOutput(Class<X> resultType) {
		throw new  IllegalOutputTypeException( "Cannot treat UpdateCountOutput as ResultSetOutput" );
	}

	@Override
	default <X> ResultSetOutput<X> asResultSetOutput(ResultSetMapping<X> resultSetMapping) {
		throw new  IllegalOutputTypeException( "Cannot treat UpdateCountOutput as ResultSetOutput" );
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Check the output type before casting: use outputs.getCurrent() instanceof ResultSetOutput.
  2. Advance through outputs with goToNext() until a result-set output is current.

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