hibernate/hibernate-orm · error · AnnotationException

Property '<path>' is the inverse side of a '@ManyToOne' asso

Error message

Property '<path>' is the inverse side of a '@ManyToOne' association and cannot be used as identifier

What it means

Error "Property '<path>' is the inverse side of a '@ManyToOne' association and cannot be used as identifier" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java:93

			boolean isIdentifierMapper,
			boolean inSecondPass,
			MetadataBuildingContext context,
			AnnotatedJoinColumns joinColumns,
			PropertyBinder propertyBinder) {
		final var memberDetails = inferredData.getAttributeMember();
		final var manyToOne = memberDetails.getDirectAnnotationUsage( ManyToOne.class );

		//check validity
		if ( memberDetails.hasDirectAnnotationUsage( Column.class ) ) {
			throw new AnnotationException(
					"Property '" + getPath( propertyHolder, inferredData )
							+ "' is a '@ManyToOne' association and may not use '@Column' to specify column mappings (use '@JoinColumn' instead)"
			);
		}

		if ( joinColumns.hasMappedBy()
				&& isIdentifier( propertyHolder, propertyBinder, isIdentifierMapper ) ) {
			throw new AnnotationException(
					"Property '" + getPath( propertyHolder, inferredData )
							+ "' is the inverse side of a '@ManyToOne' association and cannot be used as identifier"
			);
		}

		bindManyToOne(
				aggregateCascadeTypes( manyToOne.cascade(), memberDetails, false, context ),
				joinColumns,
				propertyHolder,
				nullability,
				inferredData,
				manyToOne.fetch(),
				manyToOne.optional(),
				false,
				isIdentifierMapper,
				inSecondPass,
				propertyBinder,
				context

View on GitHub (pinned to fad1729dce)

Solutions

  1. Make the owning side the identifier: put @Id (and @MapsId if deriving the id) on the side that owns the foreign key, and mark the inverse side with mappedBy.
  2. If you only need a plain association, remove @Id from the inverse-side property so it is not used as the identifier.

Example fix

Make the owning side the identifier: put @Id (and @MapsId if deriving the id) on the side that owns the foreign key, and mark the inverse side with mappedBy.

When it happens

Trigger: An entity mapping annotation or bootstrap configuration violates a Hibernate mapping rule.

Common situations: Annotation mapping mistakes: inverse-side @Id associations, @Column on @OneToOne, unmapped association targets, mismatched @EnumeratedValue/@Temporal usage, duplicate sequence generators.


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