{"record":{"id":"ce564a066970b4af","repo":"hibernate/hibernate-orm","slug":"unknown-sqlresultsetmapping-resultsetmappingn","errorCode":null,"errorMessage":"Unknown SqlResultSetMapping [\" + resultSetMappingName + \"]","messagePattern":"Unknown SqlResultSetMapping \\[\" \\+ resultSetMappingName \\+ \"\\]","errorType":"exception","errorClass":"UnknownSqlResultSetMappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java","lineNumber":79,"sourceCode":"\t\t}\n\t\telse if ( !isEmpty( resultSetMappingClasses ) ) {\n\t\t\tresolveResultSetMappingClasses( resultSetMappingClasses, resultSetMapping, querySpaceConsumer, context );\n\t\t}\n\n\t\t// otherwise, nothing to resolve\n\t}\n\n\tpublic static void resolveResultSetMappingNames(\n\t\t\tString[] resultSetMappingNames,\n\t\t\tResultSetMapping resultSetMapping,\n\t\t\tConsumer<String> querySpaceConsumer,\n\t\t\tResultSetMappingResolutionContext context) {\n\t\tfinal var namedObjectRepository = context.getNamedObjectRepository();\n\t\tfor ( String resultSetMappingName : resultSetMappingNames ) {\n\t\t\tfinal var memento =\n\t\t\t\t\tnamedObjectRepository.getResultSetMappingMemento( resultSetMappingName );\n\t\t\tif ( memento == null ) {\n\t\t\t\tthrow new UnknownSqlResultSetMappingException( \"Unknown SqlResultSetMapping [\" + resultSetMappingName + \"]\" );\n\t\t\t}\n\t\t\tmemento.resolve( resultSetMapping, querySpaceConsumer, context );\n\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 );","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java#L61-L97","documentation":"When resolving resultSetMapping names into an existing mapping, Util looks each name up in the SessionFactory's NamedObjectRepository. A null memento means no @SqlResultSetMapping was registered under that name, and it throws UnknownSqlResultSetMappingException with the offending name in brackets.","triggerScenarios":"createStoredProcedureCall(\"loadOrder\", \"orderMapping\") / em.createStoredProcedureQuery(\"loadOrder\", \"orderMapping\") where no @SqlResultSetMapping(name = \"orderMapping\") exists in the persistence unit; or @NamedStoredProcedureQuery(resultSetMappings = \"orderMaping\") with a typo.","commonSituations":"Typos between the reference and the @SqlResultSetMapping name; the mapping is defined on a class that is not part of the persistence unit (not scanned, not listed in persistence.xml); unit tests building a MetadataBuilder manually without the annotated class; mapping defined in an orm.xml file that is not included in the unit.","solutions":["Define the mapping on an entity in the same persistence unit: @SqlResultSetMapping(name = \"orderMapping\", entities = @EntityResult(entityClass = Order.class))","Fix the reference so it matches the @SqlResultSetMapping name exactly (names are exact strings)","Ensure the class holding the mapping is registered — listed in persistence.xml or inside the scanned packages","Add a startup assertion that the memento resolves before the call is used"],"exampleFix":"// before\n@NamedStoredProcedureQuery(name = \"loadOrder\", procedureName = \"load_order\",\n    resultSetMappings = \"orderMaping\") // typo, mapping never found\n\n// after\n@SqlResultSetMapping(name = \"orderMapping\", entities = @EntityResult(entityClass = Order.class))\n@NamedStoredProcedureQuery(name = \"loadOrder\", procedureName = \"load_order\",\n    resultSetMappings = \"orderMapping\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    ProcedureCall call = session.createStoredProcedureCall(\"loadOrder\", \"orderMapping\");\n} catch (org.hibernate.UnknownSqlResultSetMappingException e) {\n    // no @SqlResultSetMapping named \"orderMapping\" in this persistence unit:\n    // define it on an entity, fix the typo, or include the defining class\n}","preventionTips":["Define @SqlResultSetMapping on an @Entity inside the same persistence unit","Share mapping-name constants between definitions and call sites","Verify the defining class is listed in persistence.xml or inside scanned packages","Resolve all named mappings once at startup to fail fast"],"tags":["hibernate","stored-procedure","result-mapping","configuration","jpa-annotation"],"backgroundTag":"unknown-result-set-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}