{"record":{"id":"5c2d5d72ae7c7534","repo":"hibernate/hibernate-orm","slug":"duplicate-property-mapping-of-property-getname","errorCode":null,"errorMessage":"Duplicate property mapping of \" + property.getName() + \" found in \" + getEntityName()","messagePattern":"Duplicate property mapping of \" \\+ property\\.getName\\(\\) \\+ \" found in \" \\+ getEntityName\\(\\)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java","lineNumber":718,"sourceCode":"\t\t\t\tfinal int actualColumns = prop.getColumnSpan();\n\t\t\t\tfinal int requiredColumns = type.getColumnSpan( mapping );\n\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\t\"Property '\" + qualify( getEntityName(), prop.getName() )\n\t\t\t\t\t\t\t\t+ \"' maps to \" + actualColumns + \" columns but \" + requiredColumns\n\t\t\t\t\t\t\t\t+ \" columns are required (type '\" + type.getName()\n\t\t\t\t\t\t\t\t+ \"' spans \" + requiredColumns + \" columns)\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tcheckPropertyDuplication();\n\t\tcheckColumnDuplication();\n\t}\n\n\tprivate void checkPropertyDuplication() throws MappingException {\n\t\tfinal HashSet<String> names = new HashSet<>();\n\t\tfor ( var property : getProperties() ) {\n\t\t\tif ( !names.add( property.getName() ) ) {\n\t\t\t\tthrow new MappingException( \"Duplicate property mapping of \" + property.getName() + \" found in \" + getEntityName() );\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic boolean isDiscriminatorValueNotNull() {\n\t\treturn NOT_NULL_DISCRIMINATOR_MAPPING.equals( getDiscriminatorValue() );\n\t}\n\n\tpublic boolean isDiscriminatorValueNull() {\n\t\treturn NULL_DISCRIMINATOR_MAPPING.equals( getDiscriminatorValue() );\n\t}\n\n\tpublic Map<String, MetaAttribute> getMetaAttributes() {\n\t\treturn metaAttributes;\n\t}\n\n\tpublic void setMetaAttributes(java.util.Map<String,MetaAttribute> metas) {\n\t\tthis.metaAttributes = metas;","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java#L700-L736","documentation":"Two properties with the same name were added to one entity's property list. checkPropertyDuplication() runs during validate() and rejects the mapping because Hibernate binds property names to fields/getters uniquely. Typical causes are a subclass re-declaring an inherited property, or merged mappings defining the same property twice.","triggerScenarios":"A subclass with @Entity re-declaring a field already mapped on its root or @MappedSuperclass; XML mappings where a property element with the same name appears twice after merging files; tooling resolving both an is-getter and a get-getter as separate properties.","commonSituations":"Copy-pasting fields from parent to subclass; IDE generating duplicate field and method mappings; merging hbm.xml fragments that both define the same property.","solutions":["Find the duplicate name from the message and remove or rename one of the two mappings","For inherited state, rely on inheritance instead of re-declaring the field on the subclass","When merging XML files, de-duplicate repeated property entries"],"exampleFix":"// before\nclass Base { private String name; }                 // mapped on root\n@Entity class Sub extends Base { private String name; } // duplicate\n\n// after\n@Entity class Sub extends Base { private String subName; } // or drop the field entirely","handlingStrategy":"validation","validationCode":"Set<String> names = new HashSet<>();\nfor (Property p : pc.getProperties()) {\n    if (!names.add(p.getName())) {\n        // duplicate property name: rename or remove one mapping before validation runs\n    }\n}","typeGuard":null,"tryCatchPattern":"try { metadata.buildSessionFactory(); }\ncatch (MappingException e) {\n    if (e.getMessage().contains(\"Duplicate property mapping\")) {\n        // the message names the property and entity; remove the second declaration\n    }\n    throw e;\n}","preventionTips":["Never re-declare inherited fields on subclasses","Lint generated XML for repeated property names","Choose one access strategy (field or property) per hierarchy"],"tags":["hibernate","orm","mapping-validation","duplicate-property","inheritance"],"backgroundTag":"duplicate-property-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}