hibernate/hibernate-orm · error · AnnotationException

Association '<role>' has a '@JoinTable' with 'inverseJoinCol

Error message

Association '<role>' has a '@JoinTable' with 'inverseJoinColumns' and targets the type '<typeName>' which is not an '@Entity' type

What it means

Error "Association '<role>' has a '@JoinTable' with 'inverseJoinColumns' and targets the type '<typeName>' which is not an '@Entity' type" thrown in hibernate/hibernate-orm.

Source

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

			boolean isManyToAny) {

		if ( !isCollectionOfEntities) {
			if ( property.hasDirectAnnotationUsage( ManyToMany.class )
					|| property.hasDirectAnnotationUsage( OneToMany.class ) ) {
				throw new AnnotationException( "Association '" + safeCollectionRole() + "'"
						+ targetEntityMessage( elementType ) );
			}
			else if (isManyToAny) {
				final var joinTable = propertyHolder.getJoinTable( property );
				if ( joinTable == null ) {
					throw new AnnotationException( "Association '" + safeCollectionRole()
							+ "' is a '@ManyToAny' and must specify a '@JoinTable'" );
				}
			}
			else {
				final var joinTableAnn = propertyHolder.getJoinTable( property );
				if ( joinTableAnn != null && !ArrayHelper.isEmpty( joinTableAnn.inverseJoinColumns() ) ) {
					throw new AnnotationException( "Association '" + safeCollectionRole()
							+ " has a '@JoinTable' with 'inverseJoinColumns' and"
							+ targetEntityMessage( elementType ) );
				}
			}
		}
	}

	static String targetEntityMessage(TypeDetails elementType) {
		final String problem =
				isEntity( elementType.determineRawClass() )
						? " which does not belong to the same persistence unit"
						: " which is not an '@Entity' type";
		return " targets the type '" + elementType.getName() + "'" + problem;
	}

	private static Class<? extends EmbeddableInstantiator> resolveCustomInstantiator(
			MemberDetails property,
			TypeDetails propertyClass,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove inverseJoinColumns from the @JoinTable, or make the target type an @Entity.

When it happens

Trigger: An association or reference targets a type that Hibernate has not mapped as an entity.

Common situations: Missing @Entity on the target class, the class not being scanned into the persistence unit, or a typo in the entity name.


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