hibernate/hibernate-orm · error · AnnotationException

Collection ' ' is 'mappedBy' a property named ' ' which…

Error message

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

What it means

Inverse-side lookup failure: PersistentClass.getProperty threw while resolving the mappedBy property name in the target entity - the property named by mappedBy does not exist there. Typo in mappedBy or wrong target entity.

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.
Defensive patterns

Strategy: validation

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.

Appendix: 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)