hibernate/hibernate-orm · error · MappingException

cannot combine mapped="true" with specified name

Error message

cannot combine mapped="true" with specified name

What it means

Error "cannot combine mapped="true" with specified name" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/EntityHierarchySourceImpl.java:124

					throw new MappingException(
							"mapped composite identifier must name component class to use.",
							rootEntitySource.origin()
					);
				}
			}

			if ( StringHelper.isEmpty( compositeId.getName() ) ) {
				if ( compositeId.isMapped() && StringHelper.isEmpty( compositeId.getClazz() ) ) {
					throw new MappingException(
							"mapped composite identifier must name component class to use.",
							rootEntitySource.origin()
					);
				}
				return new IdentifierSourceNonAggregatedCompositeImpl( rootEntitySource );
			}
			else {
				if ( compositeId.isMapped() ) {
					throw new MappingException(
							"cannot combine mapped=\"true\" with specified name",
							rootEntitySource.origin()
					);
				}
				return new IdentifierSourceAggregatedCompositeImpl( rootEntitySource );
			}
		}
	}

	private static VersionAttributeSource interpretVersionSource(RootEntitySourceImpl rootEntitySource) {
		final JaxbHbmRootEntityType entityElement = rootEntitySource.jaxbEntityMapping();
		if ( entityElement.getVersion() != null ) {
			return new VersionAttributeSourceImpl(
					rootEntitySource.sourceMappingDocument(),
					rootEntitySource,
					entityElement.getVersion()
			);
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove the name attribute when mapped="true" is set on the identifier, or drop mapped="true".

Example fix

Remove the name attribute when mapped="true" is set on the identifier, or drop mapped="true".

When it happens

Trigger: An hbm.xml / orm.xml mapping document violates a mapping rule during bootstrap.

Common situations: Legacy XML mappings with invalid combinations (column+formula, mixed inheritance, missing identifiers, bad extends references).


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