{"record":{"id":"7e5163317d74c0a4","repo":"hibernate/hibernate-orm","slug":"unknown-sqlresultsetmapping-mappingname","errorCode":null,"errorMessage":"Unknown SqlResultSetMapping [\" + mappingName + \"]","messagePattern":"Unknown SqlResultSetMapping \\[\" \\+ mappingName \\+ \"\\]","errorType":"exception","errorClass":"UnknownSqlResultSetMappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java","lineNumber":100,"sourceCode":"\t\t}\n\t}\n\n\tpublic static List<ResultSetMapping> resolveResultSetMappings(\n\t\t\tString procedureName,\n\t\t\tString[] resultSetMappingNames,\n\t\t\tConsumer<String> querySpaceConsumer,\n\t\t\tResultSetMappingResolutionContext context) {\n\t\tfinal var namedObjectRepository = context.getNamedObjectRepository();\n\t\tfinal var sessionFactory = context.getSessionFactory();\n\t\tfinal List<ResultSetMapping> resultMappings = CollectionHelper.arrayList( resultSetMappingNames.length );\n\t\tfor ( int i = 0; i < resultSetMappingNames.length; i++ ) {\n\t\t\tfinal var mappingName = resultSetMappingNames[i];\n\t\t\tfinal ResultSetMapping mapping = sessionFactory\n\t\t\t\t\t.getJdbcValuesMappingProducerProvider()\n\t\t\t\t\t.buildResultSetMapping( procedureName + \":\" + mappingName, false, sessionFactory );\n\t\t\tfinal var memento = namedObjectRepository.getResultSetMappingMemento( mappingName );\n\t\t\tif ( memento == null ) {\n\t\t\t\tthrow new UnknownSqlResultSetMappingException( \"Unknown SqlResultSetMapping [\" + mappingName + \"]\" );\n\t\t\t}\n\t\t\tmemento.resolve( mapping, querySpaceConsumer, context );\n\t\t\tresultMappings.add( mapping );\n\t\t}\n\t\treturn resultMappings;\n\t}\n\n\tpublic static ResultSetMapping makeResultSetMapping(\n\t\t\tString procedureName,\n\t\t\tClass<?> resultClass,\n\t\t\tConsumer<String> querySpaceConsumer,\n\t\t\tResultSetMappingResolutionContext context) {\n\t\tfinal var sessionFactory = context.getSessionFactory();\n\t\tfinal ResultSetMapping clazzMapping = sessionFactory\n\t\t\t\t.getJdbcValuesMappingProducerProvider()\n\t\t\t\t.buildResultSetMapping( procedureName + \":\" + resultClass.getName(), false, sessionFactory );\n\t\tapplyResultClass( resultClass, clazzMapping, querySpaceConsumer, context );\n\t\treturn clazzMapping;","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java#L82-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nProcedureCall call = session.createStoredProcedureCall(\"report\", \"orders\", \"lines\"); // \"lines\" undefined\n\n// after\n@SqlResultSetMapping(name = \"lines\", columns = @ColumnResult(name = \"qty\", type = Integer.class))\n// ... then\nProcedureCall call = session.createStoredProcedureCall(\"report\", \"orders\", \"lines\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    ProcedureCall call = session.createStoredProcedureCall(\"report\", \"orders\", \"lines\");\n} catch (org.hibernate.UnknownSqlResultSetMappingException e) {\n    // one of the mapping names is unregistered: check each name against @SqlResultSetMapping definitions\n}","preventionTips":["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"],"tags":["hibernate","stored-procedure","result-mapping","configuration"],"backgroundTag":"unknown-result-set-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}