{"record":{"id":"79ef2e9a1e839724","repo":"hibernate/hibernate-orm","slug":"result-set-mapping-name-is-null","errorCode":null,"errorMessage":"Result-set mapping name is null: {}","messagePattern":"Result-set mapping name is null: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java","lineNumber":835,"sourceCode":"\t@Override\n\tpublic NamedResultSetMappingDescriptor getResultSetMapping(String name) {\n\t\treturn sqlResultSetMappingMap.get( name );\n\t}\n\n\t@Override\n\tpublic void visitNamedResultSetMappingDefinition(Consumer<NamedResultSetMappingDescriptor> definitionConsumer) {\n\t\tsqlResultSetMappingMap.values().forEach( definitionConsumer );\n\t}\n\n\t@Override\n\tpublic void addResultSetMapping(NamedResultSetMappingDescriptor resultSetMappingDescriptor) {\n\t\tif ( resultSetMappingDescriptor == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Result-set mapping was null\" );\n\t\t}\n\t\telse {\n\t\t\tfinal String name = resultSetMappingDescriptor.getRegistrationName();\n\t\t\tif ( name == null ) {\n\t\t\t\tthrow new IllegalArgumentException( \"Result-set mapping name is null: \" + resultSetMappingDescriptor );\n\t\t\t}\n\t\t\telse if ( !defaultSqlResultSetMappingNames.contains( name ) ) {\n\t\t\t\tapplyResultSetMapping( resultSetMappingDescriptor );\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void applyResultSetMapping(NamedResultSetMappingDescriptor resultSetMappingDescriptor) {\n\t\tfinal var old = sqlResultSetMappingMap.put(\n\t\t\t\tresultSetMappingDescriptor.getRegistrationName(),\n\t\t\t\tresultSetMappingDescriptor\n\t\t);\n\t\tif ( old != null ) {\n\t\t\tthrow new DuplicateMappingException(\n\t\t\t\t\tDuplicateMappingException.Type.RESULT_SET_MAPPING,\n\t\t\t\t\tresultSetMappingDescriptor.getRegistrationName()\n\t\t\t);\n\t\t}","sourceCodeStart":817,"sourceCodeEnd":853,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java#L817-L853","documentation":"A non-null result-set mapping descriptor carried a null registration name. The exception appends the descriptor's toString() to help locate it. Because @SqlResultSetMapping is referenced by name from @NamedNativeQuery(resultSetMapping=...), a nameless mapping is unusable and bootstrap stops.","triggerScenarios":"An orm.xml <sql-result-set-mapping> element without a name attribute; a builder/contributor constructing the descriptor without setting its registration name.","commonSituations":"Hand-edited orm.xml, migration tooling rewriting mappings, and programmatic descriptor construction from absent config keys.","solutions":["Identify the descriptor via the toString() output printed in the message","Add the name attribute in orm.xml, or set the name programmatically before registration","Verify the native query's resultSetMapping attribute references exactly that name"],"exampleFix":"<!-- before -->\n<sql-result-set-mapping>\n    <column-result name=\"id\"/>\n</sql-result-set-mapping>\n\n<!-- after -->\n<sql-result-set-mapping name=\"UserByIdMapping\">\n    <column-result name=\"id\"/>\n</sql-result-set-mapping>","handlingStrategy":"validation","validationCode":"if ( d == null || d.getRegistrationName() == null ) {\n    throw new IllegalStateException( \"Result-set mapping missing name: \" + d );\n}\ncollector.addResultSetMapping( d );","typeGuard":"static boolean hasRegistrationName( NamedResultSetMappingDescriptor d ) {\n    return d != null && d.getRegistrationName() != null && !d.getRegistrationName().isBlank();\n}","tryCatchPattern":"try {\n    metadata.buildSessionFactory();\n} catch ( IllegalArgumentException e ) {\n    if ( e.getMessage() != null && e.getMessage().startsWith( \"Result-set mapping name is null\" ) ) {\n        // message contains descriptor.toString() — use it to locate the mapping\n        throw new IllegalStateException( \"Nameless result-set mapping: \" + e.getMessage(), e );\n    }\n    throw e;\n}","preventionTips":["Validate orm.xml against the persistence schema in CI","Reference-check every resultSetMapping attribute against a declared mapping name","Generate mappings with tooling that enforces required attributes"],"tags":["hibernate","orm","java","bootstrap","result-set-mapping","orm-xml"],"backgroundTag":"missing-mapping-name","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}