{"record":{"id":"5aced27ddd21cf40","repo":"hibernate/hibernate-orm","slug":"column-with-logical-name-s-in-table-s-cannot","errorCode":null,"errorMessage":"Column with logical name '%s' in table '%s' cannot be mapped to column identifier","messagePattern":"Column with logical name '(.+?)' in table '(.+?)' cannot be mapped to column identifier","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java","lineNumber":1150,"sourceCode":"\t\t\tbinding = null;\n\t\t}\n\t\telse {\n\t\t\tbinding = columnNameBindingByTableMap.get( table );\n\t\t}\n\n\t\tif ( binding == null ) {\n\t\t\tbinding = new TableColumnNameBinding( table.getName() );\n\t\t\tcolumnNameBindingByTableMap.put( table, binding );\n\t\t}\n\n\t\tbinding.addBinding( logicalName, column );\n\t}\n\n\t@Override\n\tpublic String getPhysicalColumnName(Table table, String logicalName) throws MappingException {\n\t\tfinal Identifier identifier = getDatabase().toIdentifier( logicalName );\n\t\tif ( identifier == null ) {\n\t\t\tthrow new MappingException( String.format(\n\t\t\t\t\tLocale.ENGLISH,\n\t\t\t\t\t\"Column with logical name '%s' in table '%s' cannot be mapped to column identifier\",\n\t\t\t\t\tlogicalName,\n\t\t\t\t\ttable.getName()\n\t\t\t) );\n\t\t}\n\t\treturn getPhysicalColumnName( table, identifier );\n\t}\n\n\t@Override\n\tpublic String getPhysicalColumnName(Table table, Identifier logicalName) throws MappingException {\n\t\tif ( logicalName == null ) {\n\t\t\tthrow new MappingException( \"Logical column name cannot be null\" );\n\t\t}\n\n\t\tTable currentTable = table;\n\t\twhile ( currentTable != null ) {\n\t\t\tfinal TableColumnNameBinding binding = columnNameBindingByTableMap.get( currentTable );","sourceCodeStart":1132,"sourceCodeEnd":1168,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java#L1132-L1168","documentation":"getPhysicalColumnName(Table, String) converts the logical column name to an Identifier before lookup; getDatabase().toIdentifier(...) returns null for a null/blank name, and that null triggers this MappingException. It is effectively a null-argument guard on the logical-column resolution path, reached almost exclusively through programmatic or custom mapping code.","triggerScenarios":"Calling this mapping API with a null or blank logical column name: dynamic components with null keys, custom binders resolving a column name that was never set, or mapping generators emitting empty column names.","commonSituations":"Custom MetadataContributors, dynamic-map entities with malformed component keys, and code-generated mappings that leave column names empty for optional elements.","solutions":["Null/blank-check the logical name before calling the API","Validate column names when mappings are read so the malformed entry is named at load time","Log table plus property context during column-name resolution so the offending mapping is identifiable"],"exampleFix":"// before\nString physical = mapping.getPhysicalColumnName( table, columnName );\n\n// after\nif ( columnName == null || columnName.isBlank() ) {\n    throw new IllegalStateException( \"Missing logical column name for table \" + table.getName() );\n}\nString physical = mapping.getPhysicalColumnName( table, columnName );","handlingStrategy":"validation","validationCode":"if ( logicalName == null || logicalName.isBlank() ) {\n    throw new IllegalStateException( \"Missing logical column name for table \" + table.getName() );\n}\nreturn mapping.getPhysicalColumnName( table, logicalName );","typeGuard":"static boolean isResolvableLogicalColumnName( String logicalName ) {\n    return logicalName != null && !logicalName.isBlank();\n}","tryCatchPattern":"try {\n    return mapping.getPhysicalColumnName( table, logicalName );\n} catch ( MappingException e ) {\n    if ( e.getMessage() != null && e.getMessage().contains( \"cannot be mapped to column identifier\" ) ) {\n        throw new IllegalStateException( \"Null/blank logical column name for table \" + table.getName(), e );\n    }\n    throw e;\n}","preventionTips":["Validate column names when mappings are read, before resolution","Forbid null keys in dynamic component maps","Log table plus property context during column-name resolution"],"tags":["hibernate","orm","java","bootstrap","column-mapping","null-check"],"backgroundTag":"null-argument-validation","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}