{"record":{"id":"1d88faa25eb91020","repo":"hibernate/hibernate-orm","slug":"table-s-contains-physical-column-name-s-refe","errorCode":null,"errorMessage":"Table [%s] contains physical column name [%s] referred to by multiple logical column names: [%s], [%s]","messagePattern":"Table \\[(.+?)\\] contains physical column name \\[(.+?)\\] referred to by multiple logical column names: \\[(.+?)\\], \\[(.+?)\\]","errorType":"exception","errorClass":"DuplicateMappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java","lineNumber":1102,"sourceCode":"\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 );\n\t\t\tif ( existingLogicalName != null && ! existingLogicalName.equals( logicalName ) ) {\n\t\t\t\tthrow new DuplicateMappingException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ENGLISH,\n\t\t\t\t\t\t\t\t\"Table [%s] contains physical column name [%s] referred to by multiple logical \" +\n\t\t\t\t\t\t\t\t\t\t\"column names: [%s], [%s]\",\n\t\t\t\t\t\t\t\ttableName,\n\t\t\t\t\t\t\t\tphysicalName,\n\t\t\t\t\t\t\t\tlogicalName,\n\t\t\t\t\t\t\t\texistingLogicalName\n\t\t\t\t\t\t),\n\t\t\t\t\t\tDuplicateMappingException.Type.COLUMN_BINDING,\n\t\t\t\t\t\ttableName + \".\" + physicalName\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate Map<Table,TableColumnNameBinding> columnNameBindingByTableMap;\n","sourceCodeStart":1084,"sourceCodeEnd":1120,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java#L1084-L1120","documentation":"The mirror check of the logical-to-physical one: one physical column of a table was registered under a second, different logical name (Identifier equality is exact, so case or quoting differences count as different names). Because reverse resolution would be ambiguous, Hibernate throws DuplicateMappingException(Type.COLUMN_BINDING) and aborts bootstrap.","triggerScenarios":"Two properties of one entity mapped to the same physical column under different logical names — a @JoinColumn(name=\"dept_id\") association plus a basic @Column(name=\"dept_id\") field; an embeddable overridden onto a column the owner already maps; logical names differing only in case.","commonSituations":"The classic JPA 'repeated column' setup where a foreign key is exposed both as an association and as a plain field, legacy schemas mapped by multiple teams, and attribute renames that kept the old column mapping as a duplicate.","solutions":["Give the column a single owning mapping and drop the redundant property, or mark the extra one insertable=false, updatable=false","Where two mappings must coexist, align their logical names exactly (same spelling and quoting)","Use @AssociationOverride/@AttributeOverride to bind embeddables to columns not otherwise mapped in that table","Search the entity named in the message for duplicate name= values across @Column and @JoinColumn"],"exampleFix":"// before: FK column mapped twice under different logical names\n@ManyToOne\n@JoinColumn(name = \"dept_id\")\nprivate Department department;\n\n@Column(name = \"dept_id\")\nprivate Long deptId;\n\n// after: one owner; the read-only copy is non-insertable/non-updatable\n@ManyToOne\n@JoinColumn(name = \"dept_id\")\nprivate Department department;\n\n@Column(name = \"dept_id\", insertable = false, updatable = false)\nprivate Long deptId;","handlingStrategy":"try-catch","validationCode":"static void assertNoRepeatedColumns( Class<?> entity ) {\n    final Map<String, String> columnOwner = new HashMap<>();\n    for ( Class<?> c = entity; c != null && c != Object.class; c = c.getSuperclass() ) {\n        for ( final Field f : c.getDeclaredFields() ) {\n            final Column col = f.getAnnotation( Column.class );\n            final JoinColumn join = f.getAnnotation( JoinColumn.class );\n            final String name = col != null ? col.name() : ( join != null ? join.name() : null );\n            if ( name != null && !name.isEmpty() ) {\n                final String prev = columnOwner.put( name.toLowerCase( Locale.ROOT ), f.getName() );\n                if ( prev != null ) {\n                    throw new IllegalStateException( \"Column '\" + name + \"' mapped by both '\" + prev + \"' and '\" + f.getName() + \"'\" );\n                }\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 logical\" ) ) {\n        // one physical column referenced under two different logical names in the named table\n        throw new IllegalStateException( \"Repeated column mapping: \" + e.getMessage(), e );\n    }\n    throw e;\n}","preventionTips":["Give each physical column exactly one owning mapping","Mark read-only duplicates insertable=false, updatable=false","Use @AssociationOverride/@AttributeOverride for embeddables sharing tables with their owner","After renaming an attribute, delete its old column mapping instead of leaving both"],"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"}