hibernate/hibernate-orm · error · AnnotationException

Property '" + getPath( propertyHolder, inferredData ) + "' i

Error message

Property '" + getPath( propertyHolder, inferredData ) + "' is a '@ManyToOne' association and may not use '@Column' to specify column mappings (use '@JoinColumn' instead)

What it means

Error "Property '" + getPath( propertyHolder, inferredData ) + "' is a '@ManyToOne' association and may not use '@Column' to specify column mappings (use '@JoinColumn' instead)" thrown in hibernate/hibernate-orm.

Source

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

 * @author Emmanuel Bernard
 */
public class ToOneBinder {

	static void bindManyToOne(
			PropertyHolder propertyHolder,
			Nullability nullability,
			PropertyData inferredData,
			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,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Replace @Column with @JoinColumn on the @ManyToOne association.

When it happens

Trigger: A '@JoinColumn' / 'referencedColumnName' does not line up with the columns mapped by the target entity.

Common situations: Composite foreign keys, associations to entities with secondary tables, or reordered/duplicated referencedColumnName values across multiple @JoinColumn declarations.


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