hibernate/hibernate-orm · error · AnnotationException

Collection '<role>' is 'mappedBy' a property named '<mappedB

Error message

Collection '<role>' is 'mappedBy' a property named '<mappedBy>' which does not exist in the target entity '<entityName>'

What it means

Error "Collection '<role>' is 'mappedBy' a property named '<mappedBy>' which does not exist in the target entity '<entityName>'" thrown in hibernate/hibernate-orm.

Source

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

			TypeDetails elementType,
			PersistentClass persistentClass,
			Map<String, PersistentClass> persistentClasses) {
		if ( persistentClass != null && isUnownedCollection() ) {
			final var mappedByProperty = getMappedByProperty( elementType, persistentClass );
			checkMappedByType( mappedBy, mappedByProperty.getValue(), propertyName, propertyHolder, persistentClasses );
			return persistentClass.getJoinNumber( mappedByProperty ) != 0;
		}
		else {
			return false;
		}
	}

	private Property getMappedByProperty(TypeDetails elementType, PersistentClass persistentClass) {
		try {
			return persistentClass.getRecursiveProperty( mappedBy );
		}
		catch (MappingException e) {
			throw new AnnotationException(
					"Collection '" + safeCollectionRole()
					+ "' is 'mappedBy' a property named '" + mappedBy
					+ "' which does not exist in the target entity '" + elementType.getName() + "'"
			);
		}
	}

	private boolean noAssociationTable(Map<String, PersistentClass> persistentClasses) {
		final var persistentClass = persistentClasses.get( getElementType().getName() );
		return persistentClass != null
			&& !isReversePropertyInJoin( getElementType(), persistentClass, persistentClasses )
			&& oneToMany
			&& !isExplicitAssociationTable
			&& ( implicitJoinColumn() || explicitForeignJoinColumn() );
	}

	private boolean implicitJoinColumn() {
		return joinColumns.getJoinColumns().get(0).isImplicit()

View on GitHub (pinned to fad1729dce)

Solutions

  1. Correct the mappedBy value to the name of an existing property in the target entity.
  2. Or add the missing property to the target entity.

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/f465eea41eb7e1ec. Report an issue: GitHub.