{"record":{"id":"64245964aa62c83c","repo":"hibernate/hibernate-orm","slug":"table-s-contains-logical-column-name-s-refer","errorCode":null,"errorMessage":"Table [%s] contains logical column name [%s] referring to multiple physical column names: [%s], [%s]","messagePattern":"Table \\[(.+?)\\] contains logical column name \\[(.+?)\\] referring to multiple physical column names: \\[(.+?)\\], \\[(.+?)\\]","errorType":"exception","errorClass":"DuplicateMappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java","lineNumber":1082,"sourceCode":"\n\t\tprivate TableColumnNameBinding(String tableName) {\n\t\t\tthis.tableName = tableName;\n\t\t}\n\n\t\tpublic void addBinding(Identifier logicalName, Column physicalColumn) {\n\t\t\tfinal String physicalNameString = physicalColumn.getQuotedName( getDialect() );\n\t\t\tbindLogicalToPhysical( logicalName, physicalNameString );\n\t\t\tbindPhysicalToLogical( logicalName, physicalNameString );\n\t\t}\n\n\t\tprivate void bindLogicalToPhysical(Identifier logicalName, String physicalName) throws DuplicateMappingException {\n\t\t\tfinal String existingPhysicalNameMapping = logicalToPhysical.put( logicalName, physicalName );\n\t\t\tif ( existingPhysicalNameMapping != null ) {\n\t\t\t\tfinal boolean areSame = logicalName.isQuoted()\n\t\t\t\t\t\t? physicalName.equals( existingPhysicalNameMapping )\n\t\t\t\t\t\t: physicalName.equalsIgnoreCase( existingPhysicalNameMapping );\n\t\t\t\tif ( !areSame ) {\n\t\t\t\t\tthrow new DuplicateMappingException(\n\t\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\t\tLocale.ENGLISH,\n\t\t\t\t\t\t\t\t\t\"Table [%s] contains logical column name [%s] referring to multiple physical \" +\n\t\t\t\t\t\t\t\t\t\t\t\"column names: [%s], [%s]\",\n\t\t\t\t\t\t\t\t\ttableName,\n\t\t\t\t\t\t\t\t\tlogicalName,\n\t\t\t\t\t\t\t\t\texistingPhysicalNameMapping,\n\t\t\t\t\t\t\t\t\tphysicalName\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tDuplicateMappingException.Type.COLUMN_BINDING,\n\t\t\t\t\t\t\ttableName + \".\" + logicalName\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprivate void bindPhysicalToLogical(Identifier logicalName, String physicalName) throws DuplicateMappingException {\n\t\t\tfinal Identifier existingLogicalName = physicalToLogical.put( physicalName, logicalName );","sourceCodeStart":1064,"sourceCodeEnd":1100,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java#L1064-L1100","documentation":"Inside one table's column-binding registry, the same logical column name was bound to a second physical name that differs (the comparison is case-insensitive unless the logical name is quoted). Hibernate keeps exactly one logical-to-physical mapping per table, so the conflicting binding raises DuplicateMappingException(Type.COLUMN_BINDING) and bootstrap stops.","triggerScenarios":"The same logical attribute of one table mapped twice with different @Column names — attribute overrides in an inheritance hierarchy remapping an inherited attribute to a different physical column; duplicated column declarations between hbm.xml and annotations; one binding quoted and the other not so the names compare unequal.","commonSituations":"Inheritance hierarchies with per-subclass @AttributeOverride, embeddables reused with different overrides inside one table, and mixes of annotation and XML mappings for a single hierarchy; migrations that renamed a column in only part of the mappings.","solutions":["Make the physical names identical — and identically quoted — for the logical name shown in the message","Remove the redundant second mapping of that logical column","Keep @AttributeOverride values for the same inherited attribute consistent across the hierarchy","Use a single mapping style (annotations or hbm.xml) per hierarchy so columns are not bound twice"],"exampleFix":"// before: inherited attribute overridden to two different physical columns\n@AttributeOverride(name = \"startDate\", column = @Column(name = \"start_date\")) // subclass A\n@AttributeOverride(name = \"startDate\", column = @Column(name = \"begin_date\")) // subclass B, same table\n\n// after: one physical column for the logical name\n@AttributeOverride(name = \"startDate\", column = @Column(name = \"start_date\")) // both subclasses","handlingStrategy":"try-catch","validationCode":"static void assertNoConflictingColumnOverrides( Class<?> root ) {\n    final Map<String, String> logicalToPhysical = new HashMap<>();\n    for ( Class<?> c = root; c != null && c != Object.class; c = c.getSuperclass() ) {\n        for ( final Field f : c.getDeclaredFields() ) {\n            final Column col = f.getAnnotation( Column.class );\n            if ( col == null || col.name().isEmpty() ) {\n                continue;\n            }\n            final String prev = logicalToPhysical.put( f.getName(), col.name() );\n            if ( prev != null && !prev.equalsIgnoreCase( col.name() ) ) {\n                throw new IllegalStateException( \"Field '\" + f.getName() + \"' bound to two physical columns: \" + prev + \" and \" + col.name() );\n            }\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    sessionFactory = metadata.buildSessionFactory();\n} catch ( DuplicateMappingException e ) {\n    if ( e.getType() == DuplicateMappingException.Type.COLUMN_BINDING\n            && e.getMessage() != null && e.getMessage().contains( \"multiple physical\" ) ) {\n        // one logical column name in the named table maps to two different physical columns\n        throw new IllegalStateException( \"Conflicting column binding: \" + e.getMessage(), e );\n    }\n    throw e;\n}","preventionTips":["Keep @AttributeOverride values for an inherited attribute identical across the hierarchy","Use exactly one mapping style per hierarchy to avoid double column binding","Match quoting when repeating column names","Review column renames across all mappings, not just the entity that owns the column"],"tags":["hibernate","orm","java","bootstrap","column-mapping","duplicate-mapping"],"backgroundTag":"duplicate-column-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}