hibernate/hibernate-orm · error · IllegalArgumentException

Parameter [" + parameter + "] is not registered with this pr

Error message

Parameter [" + parameter + "] is not registered with this procedure call

What it means

getOutputParameterValue looks the passed parameter up in this call's parameterRegistrations map, keyed by the exact ProcedureParameter instance. If the argument was never registered on this ProcedureCall — typically a handle obtained from a different ProcedureCall instance — the lookup returns null and Hibernate throws IllegalArgumentException('Parameter [...] is not registered with this procedure call').

Source

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

				throw convert( e, "Error calling CallableStatement.getUpdateCount" );
			}
		}

		return buildCurrentReturnState( isResultSet, updateCount );
	}

	protected CurrentReturnState buildCurrentReturnState(boolean isResultSet, int updateCount) {
		return new CurrentReturnState( this, isResultSet, updateCount );
	}

	@Override
	public <T> T getOutputParameterValue(ProcedureParameter<T> parameter) {
		if ( parameter.getMode() == ParameterMode.IN ) {
			throw new ParameterMisuseException( "IN parameter not valid for output extraction" );
		}
		final var registration = parameterRegistrations.get( parameter );
		if ( registration == null ) {
			throw new IllegalArgumentException( "Parameter [" + parameter + "] is not registered with this procedure call" );
		}
		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()
				);
			}
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use the name/position overloads — getOutputParameterValue(String name) / getOutputParameterValue(int position) — which resolve against this call's own parameter metadata.
  2. Always obtain the handle from the same instance you execute: proc.getParameter(name).
  3. Never share ProcedureParameter instances across ProcedureCall instances; they are per-call state.

Example fix

// before
StoredProcedureQuery other = em.createStoredProcedureQuery("pkg.p1");
Parameter<Integer> stale = other.getParameter("out1");
Object v = proc.getOutputParameterValue(stale); // not registered on proc

// after
Object v = proc.getOutputParameterValue("out1"); // resolves via this call's metadata
Defensive patterns

Strategy: validation

Validate before calling

// resolve the parameter against THIS call before extracting
boolean registered = proc.getParameters().stream()
        .anyMatch( p -> Objects.equals( p.getName(), name ) );
if ( !registered ) {
    throw new IllegalArgumentException( name + " not registered on this procedure call" );
}
Object value = proc.getOutputParameterValue( name ); // name/position overload resolves internally

Try / catch

try {
    Object v = proc.getOutputParameterValue( parameter );
} catch (IllegalArgumentException e) {
    if ( e.getMessage() != null && e.getMessage().contains( "not registered" ) ) {
        Object v = proc.getOutputParameterValue( parameter.getName() ); // re-resolve by name
    } else { throw e; }
}

Prevention

When it happens

Trigger: Passing a ProcedureParameter obtained from another StoredProcedureQuery/ProcedureCall (e.g. a cached or statically held parameter object); extracting with a parameter created before this call's registrations were made.

Common situations: Caching ProcedureParameter objects in fields/maps and reusing them across calls or sessions; copy-pasted parameter handling shared between two procedures; integration code that builds the query in one layer and extracts outputs in another with mixed instances.

Related errors


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