hibernate/hibernate-orm · error · AnnotationException

Association '{}' is 'mappedBy' another entity and may not sp

Error message

Association '{}' is 'mappedBy' another entity and may not specify the '@JoinTable'

What it means

Error "Association '{}' is 'mappedBy' another entity and may not specify the '@JoinTable'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java:1196

	private void bindCache() {
		//set cache
		if ( isNotBlank( cacheConcurrencyStrategy ) ) {
			collection.setCacheConcurrencyStrategy( cacheConcurrencyStrategy );
			collection.setCacheRegionName( cacheRegionName );
		}
		collection.setQueryCacheLayout( queryCacheLayout );
	}

	private void detectMappedByProblem(boolean isMappedBy) {
		if ( isMappedBy ) {
			if ( property.hasDirectAnnotationUsage( JoinColumn.class )
					|| property.hasDirectAnnotationUsage( JoinColumns.class ) ) {
				throw new AnnotationException( "Association '"
						+ qualify( propertyHolder.getPath(), propertyName )
						+ "' is 'mappedBy' another entity and may not specify the '@JoinColumn'" );
			}
			if ( propertyHolder.getJoinTable( property ) != null ) {
				throw new AnnotationException( "Association '"
						+ qualify( propertyHolder.getPath(), propertyName )
						+ "' is 'mappedBy' another entity and may not specify the '@JoinTable'" );
			}
			if ( oneToMany ) {
				if ( property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) {
					BOOT_LOGGER.mappedByShouldNotSpecifyMapKeyColumn(
							qualify( propertyHolder.getPath(), propertyName )
					);
				}
				if ( property.hasDirectAnnotationUsage( OrderColumn.class ) ) {
					BOOT_LOGGER.mappedByShouldNotSpecifyOrderColumn(
							qualify( propertyHolder.getPath(), propertyName )
					);
				}
			}
			else {
				if ( property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) {
					throw new AnnotationException( "Association '"

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove @JoinTable from the unowned (mappedBy) side; the owning side declares the join table.

When it happens

Trigger: An association declares 'mappedBy' naming a property that does not exist, has the wrong type, or is not the owning side on the target entity.

Common situations: Bidirectional associations where mappedBy is misspelled, both sides claim ownership, or the target entity was refactored without updating the mapping.


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