{"record":{"id":"2cf0ef82077e4994","repo":"hibernate/hibernate-orm","slug":"entity-class-s-mapped-multiple-times-with-diffe","errorCode":null,"errorMessage":"Entity class [%s] mapped multiple times with different entity-names [%s, %s]; while this was supported in legacy hbm.xml, it is no longer supported in mapping.xml","messagePattern":"Entity class \\[(.+?)\\] mapped multiple times with different entity-names \\[(.+?), (.+?)\\]; while this was supported in legacy hbm\\.xml, it is no longer supported in mapping\\.xml","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/BootModelPreprocessor.java","lineNumber":47,"sourceCode":"\tstatic void preprocessBooModel(MetadataImplementor bootModel, TransformationState transformationState) {\n\t\tentityByNameMap.clear();\n\n\t\tbootModel.getEntityBindings().forEach( (persistentClass) -> {\n\t\t\tfinal Table table = TransformationHelper.determineEntityTable( persistentClass );\n\t\t\tfinal EntityTypeInfo entityTypeInfo = new EntityTypeInfo( table, persistentClass );\n\t\t\ttransformationState.getEntityInfoByName().put( persistentClass.getEntityName(), entityTypeInfo );\n\t\t\tbuildPersistentClassPropertyInfos( persistentClass, entityTypeInfo, transformationState );\n\t\t} );\n\t}\n\n\tprivate static void buildPersistentClassPropertyInfos(\n\t\t\tPersistentClass persistentClass,\n\t\t\tEntityTypeInfo entityTypeInfo,\n\t\t\tTransformationState transformationState) {\n\t\tif ( persistentClass.getClassName() != null ) {\n\t\t\tfinal String previous = entityByNameMap.put( persistentClass.getClassName(), persistentClass.getEntityName() );\n\t\t\tif ( previous != null ) {\n\t\t\t\tthrow new MappingException( String.format(\n\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\"Entity class [%s] mapped multiple times with different entity-names [%s, %s]; while this was supported in legacy hbm.xml, it is no longer supported in mapping.xml\",\n\t\t\t\t\t\tpersistentClass.getClassName(),\n\t\t\t\t\t\tprevious,\n\t\t\t\t\t\tpersistentClass.getEntityName()\n\t\t\t\t) );\n\t\t\t}\n\t\t}\n\n\t\tif ( persistentClass instanceof RootClass rootClass ) {\n\t\t\tif ( persistentClass.getIdentifierProperty() != null ) {\n\t\t\t\tif ( persistentClass.getIdentifierProperty().getValue() instanceof Component component ) {\n\t\t\t\t\tfinal String idPropertyName = persistentClass.getIdentifierProperty().getName();\n\t\t\t\t\tfinal String componentRole = rootClass.getEntityName() + \".\" + idPropertyName;\n\t\t\t\t\tbuildComponentEntries( componentRole, component, transformationState );\n\t\t\t\t\tregisterCompositeIdMappableAttributes(\n\t\t\t\t\t\t\trootClass.getEntityName(), idPropertyName, component, transformationState\n\t\t\t\t\t);","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/BootModelPreprocessor.java#L29-L65","documentation":"Error \"Entity class [%s] mapped multiple times with different entity-names [%s, %s]; while this was supported in legacy hbm.xml, it is no longer supported in mapping.xml\" thrown in hibernate/hibernate-orm.","triggerScenarios":"One class is mapped with several entity names, which mapping.xml no longer supports.","commonSituations":"Transforming legacy hbm.xml that maps the same class multiple times with different entity-name attributes.","solutions":["Map the entity class only once in mapping.xml; multiple entity-name mappings of one class are no longer supported.","If two logical entities over one class are required, split into two distinct subclasses or keep legacy hbm.xml instead of transforming.","Remove duplicate <class> entries for the same class from the transformed mapping."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}