hibernate/hibernate-orm · error · ExecutionException

Error extracting procedure output parameter value [" + param

Error message

Error extracting procedure output parameter value [" + parameter + "]

What it means

This ExecutionException is a wrapper: after execution, Hibernate asked the JDBC CallableStatement for the output value (via ParameterExtractor or RefCursorExtractor) and the driver threw. The real reason is in the cause — typical cases are reading an output parameter before all result sets/update counts are consumed, a Java type registered that the SQL type won't coerce to, or REF_CURSOR extraction when the statement does not supply a result set.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/procedure/internal/OutputsImpl.java:144

		try {
			if ( registration.getParameterMode() == ParameterMode.REF_CURSOR ) {
				//noinspection unchecked
				return (T) registration.getRefCursorExtractor().extractResultSet(
						jdbcStatement,
						procedureCall.getSession()
				);
			}
			else {
				//noinspection unchecked
				return (T) registration.getParameterExtractor().extractValue(
						jdbcStatement,
						parameter.getPosition() == null,
						procedureCall.getSession()
				);
			}
		}
		catch (Exception e) {
			throw new ExecutionException(
					"Error extracting procedure output parameter value [" + parameter + "]",
					e
			);
		}
	}

	@Override
	public Object getOutputParameterValue(String name) {
		return getOutputParameterValue( procedureCall.getParameterMetadata().getQueryParameter( name ) );
	}

	@Override
	public Object getOutputParameterValue(int position) {
		return getOutputParameterValue( procedureCall.getParameterMetadata().getQueryParameter( position ) );
	}


	@Override

View on GitHub (pinned to fad1729dce)

Solutions

  1. Call execute() first and consume all results (hasMoreResults()/getResultList()/getUpdateCount loop) before reading output parameters.
  2. Unwrap the ExecutionException's cause and fix the registered Java type to match the SQL OUT type.
  3. For REF_CURSOR parameters, register java.sql.ResultSet (ParameterMode.REF_CURSOR) and read it while the statement is open.

Example fix

// before
proc.execute();
Object v = proc.getOutputParameterValue("status"); // driver fails mid-extraction

// after
proc.execute();
while (proc.hasMoreResults()) { proc.getResultList(); } // drain results first
Object v = proc.getOutputParameterValue("status");
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure execute() has run and results are drained before extraction
boolean executed = proc.execute();
while ( proc.hasMoreResults() ) {
    proc.getResultList();
}
if ( proc.getUpdateCount() != -1 ) { /* update count consumed */ }
Object value = proc.getOutputParameterValue( name );

Try / catch

try {
    Object v = proc.getOutputParameterValue( name );
} catch (org.hibernate.ExecutionException e) {
    Throwable cause = e.getCause(); // the actual SQLException / driver failure
    log.warn( "output parameter [{}] extraction failed: {}", name, cause.getMessage() );
    throw new IllegalStateException( "procedure " + proc.getProcedureName() + " output failed", cause );
}

Prevention

When it happens

Trigger: getOutputParameterValue(...) before execute() completes or before draining returned result sets; registering e.g. String.class for a NUMBER OUT parameter; extracting a REF_CURSOR after the statement/cursor was closed; calling extraction twice on drivers that invalidate the value.

Common situations: PostgreSQL/Oracle ordering rules (output values valid only after results are drained); type guesses during schema evolution (column widened to NUMBER); long-running procedures where the driver times out and the CallableStatement is unusable.

Related errors


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