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
@OverrideView on GitHub (pinned to fad1729dce)
Solutions
- Verify the exact, case-sensitive name matches @NamedStoredProcedureQuery(name = ...).
- Ensure the annotation is on an entity class included in the persistence unit (auto-detection or persistence.xml <class> entry).
- 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
- Define procedure names as constants shared between annotation and caller
- Keep @NamedStoredProcedureQuery on entities listed in the persistence unit
- Smoke-test named procedure calls at startup in environments with explicit persistence.xml
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
- NamedStoredProcedureQuery [%s] specified both resultClasses
- Duplicate named query '%s'
- Duplicate named stored procedure '{}'
- Class or package level '@NamedStoredProcedureQuery' annotati
- Transaction is not accessible when using JTA with JPA-compli
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/2337f4e3bba2aef3.
Report an issue: GitHub.