hibernate/hibernate-orm · error · AnnotationException

Property '<path>' is a '@OneToOne' association and may not u

Error message

Property '<path>' is a '@OneToOne' association and may not use '@Column' to specify column mappings (use '@PrimaryKeyJoinColumn' instead)

What it means

Error "Property '<path>' is a '@OneToOne' association and may not use '@Column' to specify column mappings (use '@PrimaryKeyJoinColumn' instead)" thrown in hibernate/hibernate-orm.

Source

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

				? context.getEffectiveDefaults().isDefaultEntityLaziness() ? LAZY : EAGER
				: specifiedType;
	}

	static void bindOneToOne(
			PropertyHolder propertyHolder,
			Nullability nullability,
			PropertyData inferredData,
			boolean isIdentifierMapper,
			boolean inSecondPass,
			MetadataBuildingContext context,
			AnnotatedJoinColumns joinColumns,
			PropertyBinder propertyBinder) {
		final var memberDetails = inferredData.getAttributeMember();
		final var oneToOne = memberDetails.getDirectAnnotationUsage( OneToOne.class );

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

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

		//FIXME support a proper PKJCs
		final boolean trueOneToOne = memberDetails.hasDirectAnnotationUsage( PrimaryKeyJoinColumn.class )
				|| memberDetails.hasDirectAnnotationUsage( PrimaryKeyJoinColumns.class );
		bindOneToOne(
				aggregateCascadeTypes( oneToOne.cascade(), memberDetails, oneToOne.orphanRemoval(), context ),

View on GitHub (pinned to fad1729dce)

Solutions

  1. Replace @Column on the @OneToOne association with @JoinColumn (or @PrimaryKeyJoinColumn when the primary key is shared).
  2. Column mappings belong on basic attributes only; move any column customization to the join column of the association.

Example fix

Replace @Column on the @OneToOne association with @JoinColumn (or @PrimaryKeyJoinColumn when the primary key is shared).

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