hibernate/hibernate-orm · error · IllegalArgumentException

No named stored procedure call with given name '{}'

Error message

No named stored procedure call with given name '{}'

What it means

getNamedProcedureCall()/createNamedStoredProcedureQuery(name) resolves the name against @NamedStoredProcedureQuery registrations in the factory's named-object repository. Nothing registered under that name means the stored-procedure metadata was never deployed, so IllegalArgumentException('No named stored procedure call with given name <name>') is thrown at call creation, before any JDBC work.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java:2329

			final var query = new NativeQueryImpl<>( sql, true, this );
			applyQuerySettingsAndHints( query );
			return query;
		}
		catch ( RuntimeException e ) {
			throw getExceptionConverter().convert( e );
		}
	}

	@Override
	@Nonnull
	public ProcedureCall getNamedProcedureCall(@Nonnull String name) {
		checkOpen();

		final var memento =
				factory.getQueryEngine().getNamedObjectRepository()
						.getCallableQueryMemento( name );
		if ( memento == null ) {
			throw new IllegalArgumentException( "No named stored procedure call with given name '" + name + "'" );
		}
		@SuppressWarnings("UnnecessaryLocalVariable")
		final var procedureCall = memento.makeProcedureCall( this );
//		procedureCall.setComment( "Named stored procedure call [" + name + "]" );
		return procedureCall;
	}

	@Override
	@Nonnull
	public ProcedureCall createNamedStoredProcedureQuery(@Nonnull String name) {
		return getNamedProcedureCall( name );
	}


	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// dynamic ProcedureCall support

	@Override

View on GitHub (pinned to fad1729dce)

Solutions

  1. Verify the exact, case-sensitive name matches @NamedStoredProcedureQuery(name = ...).
  2. Ensure the annotation is on an entity class included in the persistence unit (auto-detection or persistence.xml <class> entry).
  3. If a dynamic call is acceptable, build it with createStoredProcedureCall(procName)/StoredProcedureQuery parameters instead of the named form.

Example fix

// before
StoredProcedureQuery q = em.createNamedStoredProcedureQuery("calcBonus"); // not registered
// after
@Entity
@NamedStoredProcedureQuery(name = "calcBonus", procedureName = "CALC_BONUS",
    parameters = @StoredProcedureParameter(mode = ParameterMode.IN, name = "empId", type = Long.class))
public class Employee { ... }
StoredProcedureQuery q = em.createNamedStoredProcedureQuery("calcBonus");
Defensive patterns

Strategy: try-catch

Validate before calling

// Optional: verify registration at startup (Hibernate SPI)
NamedObjectRepository named = ((SessionFactoryImplementor) sessionFactory)
        .getQueryEngine().getNamedObjectRepository();
if (named.getCallableQueryMemento(procedureName) == null) {
    throw new IllegalStateException(
        "Missing @NamedStoredProcedureQuery '" + procedureName + "'");
}

Try / catch

try {
    return em.createNamedStoredProcedureQuery(name);
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().contains("No named stored procedure call")) {
        // fall back to a dynamic call built from explicit parameters
        return em.createStoredProcedureQuery("CALC_BONUS", paramTypes());
    }
    throw e;
}

Prevention

When it happens

Trigger: Referencing a procedure name that is not registered: @NamedStoredProcedureQuery missing or typo'd, defined on a class outside persistence-unit scanning, XML descriptor mismatch, or the annotation living in a different persistence unit.

Common situations: Rename refactors of stored-procedure annotations; new entities with the annotation not listed in an explicit persistence.xml; test persistence units missing the annotated entity; copying service code between microservices without copying the annotation.

Related errors


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