hibernate/hibernate-orm · error · MappingException

Entity class [%s] mapped multiple times with different entit

Error message

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

What it means

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.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/BootModelPreprocessor.java:47

	static void preprocessBooModel(MetadataImplementor bootModel, TransformationState transformationState) {
		entityByNameMap.clear();

		bootModel.getEntityBindings().forEach( (persistentClass) -> {
			final Table table = TransformationHelper.determineEntityTable( persistentClass );
			final EntityTypeInfo entityTypeInfo = new EntityTypeInfo( table, persistentClass );
			transformationState.getEntityInfoByName().put( persistentClass.getEntityName(), entityTypeInfo );
			buildPersistentClassPropertyInfos( persistentClass, entityTypeInfo, transformationState );
		} );
	}

	private static void buildPersistentClassPropertyInfos(
			PersistentClass persistentClass,
			EntityTypeInfo entityTypeInfo,
			TransformationState transformationState) {
		if ( persistentClass.getClassName() != null ) {
			final String previous = entityByNameMap.put( persistentClass.getClassName(), persistentClass.getEntityName() );
			if ( previous != null ) {
				throw new MappingException( String.format(
						Locale.ROOT,
						"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",
						persistentClass.getClassName(),
						previous,
						persistentClass.getEntityName()
				) );
			}
		}

		if ( persistentClass instanceof RootClass rootClass ) {
			if ( persistentClass.getIdentifierProperty() != null ) {
				if ( persistentClass.getIdentifierProperty().getValue() instanceof Component component ) {
					final String idPropertyName = persistentClass.getIdentifierProperty().getName();
					final String componentRole = rootClass.getEntityName() + "." + idPropertyName;
					buildComponentEntries( componentRole, component, transformationState );
					registerCompositeIdMappableAttributes(
							rootClass.getEntityName(), idPropertyName, component, transformationState
					);

View on GitHub (pinned to fad1729dce)

Solutions

  1. Map the entity class only once in mapping.xml; multiple entity-name mappings of one class are no longer supported.
  2. If two logical entities over one class are required, split into two distinct subclasses or keep legacy hbm.xml instead of transforming.
  3. Remove duplicate <class> entries for the same class from the transformed mapping.

When it happens

Trigger: One class is mapped with several entity names, which mapping.xml no longer supports.

Common situations: Transforming legacy hbm.xml that maps the same class multiple times with different entity-name attributes.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/2cf0ef82077e4994. Report an issue: GitHub.