hibernate/hibernate-orm · error · UnknownSqlResultSetMappingException
Unknown SqlResultSetMapping [" + mappingName + "]
Error message
Unknown SqlResultSetMapping [" + mappingName + "]
What it means
The list-building variant: for each resultSetMappingName, Util builds a fresh ResultSetMapping (keyed procedureName:mappingName) and looks the name up in the NamedObjectRepository. The first name without a memento throws UnknownSqlResultSetMappingException, aborting the whole resolution loop.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java:100
}
}
public static List<ResultSetMapping> resolveResultSetMappings(
String procedureName,
String[] resultSetMappingNames,
Consumer<String> querySpaceConsumer,
ResultSetMappingResolutionContext context) {
final var namedObjectRepository = context.getNamedObjectRepository();
final var sessionFactory = context.getSessionFactory();
final List<ResultSetMapping> resultMappings = CollectionHelper.arrayList( resultSetMappingNames.length );
for ( int i = 0; i < resultSetMappingNames.length; i++ ) {
final var mappingName = resultSetMappingNames[i];
final ResultSetMapping mapping = sessionFactory
.getJdbcValuesMappingProducerProvider()
.buildResultSetMapping( procedureName + ":" + mappingName, false, sessionFactory );
final var memento = namedObjectRepository.getResultSetMappingMemento( mappingName );
if ( memento == null ) {
throw new UnknownSqlResultSetMappingException( "Unknown SqlResultSetMapping [" + mappingName + "]" );
}
memento.resolve( mapping, querySpaceConsumer, context );
resultMappings.add( mapping );
}
return resultMappings;
}
public static ResultSetMapping makeResultSetMapping(
String procedureName,
Class<?> resultClass,
Consumer<String> querySpaceConsumer,
ResultSetMappingResolutionContext context) {
final var sessionFactory = context.getSessionFactory();
final ResultSetMapping clazzMapping = sessionFactory
.getJdbcValuesMappingProducerProvider()
.buildResultSetMapping( procedureName + ":" + resultClass.getName(), false, sessionFactory );
applyResultClass( resultClass, clazzMapping, querySpaceConsumer, context );
return clazzMapping;View on GitHub (pinned to fad1729dce)
Solutions
- Verify every name in the array has a matching @SqlResultSetMapping in the same persistence unit
- Share mapping-name constants between the annotation definitions and the call sites to prevent drift
- Resolve all mappings eagerly at startup so a bad name fails during bootstrap, not at first procedure call
Example fix
// before
ProcedureCall call = session.createStoredProcedureCall("report", "orders", "lines"); // "lines" undefined
// after
@SqlResultSetMapping(name = "lines", columns = @ColumnResult(name = "qty", type = Integer.class))
// ... then
ProcedureCall call = session.createStoredProcedureCall("report", "orders", "lines"); Defensive patterns
Strategy: try-catch
Try / catch
try {
ProcedureCall call = session.createStoredProcedureCall("report", "orders", "lines");
} catch (org.hibernate.UnknownSqlResultSetMappingException e) {
// one of the mapping names is unregistered: check each name against @SqlResultSetMapping definitions
} Prevention
- Verify every mapping name in the array has a matching @SqlResultSetMapping
- Rename mappings in one commit together with all call sites
- Build the SessionFactory in tests so missing mappings fail during bootstrap
When it happens
Trigger: Passing several mapping names (createStoredProcedureCall(name, "m1", "m2")) where at least one — the first unmatched one in array order — has no @SqlResultSetMapping registered in the SessionFactory.
Common situations: Multi-result-set procedures where one mapping name drifted or was removed; renaming a @SqlResultSetMapping without updating all call sites; mappings held in a different module that is not on the persistence unit classpath.
Related errors
- Cannot specify both result-set mapping names and classes
- Unknown SqlResultSetMapping [" + resultSetMappingName + "]
- Output type [%s] cannot be assigned to requested type [%s]
- JDBC driver does not support named parameters for setArray.
- GaussDB only supports REF_CURSOR parameters as the first par
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/7e5163317d74c0a4.
Report an issue: GitHub.