hibernate/hibernate-orm · error · AnnotationException

Property '<path>' is annotated '@Any' and must declare at le

Error message

Property '<path>' is annotated '@Any' and must declare at least one '@JoinColumn'

What it means

Error "Property '<path>' is annotated '@Any' and must declare at least one '@JoinColumn'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/ColumnsBuilder.java:125

						|| property.hasDirectAnnotationUsage( OneToOne.class ) ) ) {
			joinColumns = buildDefaultJoinColumnsForToOne( property, inferredData );
		}
		else if ( joinColumns == null
				&& ( property.hasDirectAnnotationUsage( OneToMany.class )
						|| property.hasDirectAnnotationUsage( ElementCollection.class ) ) ) {
			final var oneToMany = property.getDirectAnnotationUsage( OneToMany.class );
			joinColumns = AnnotatedJoinColumns.buildJoinColumns(
					null,
					oneToMany == null ? null : nullIfEmpty( oneToMany.mappedBy() ),
					entityBinder.getSecondaryTables(),
					propertyHolder,
					inferredData,
					buildingContext
			);
		}
		else if ( joinColumns == null
				&& property.hasDirectAnnotationUsage( Any.class ) ) {
			throw new AnnotationException( "Property '" + getPath( propertyHolder, inferredData )
					+ "' is annotated '@Any' and must declare at least one '@JoinColumn'" );
		}
		if ( columns == null && !property.hasDirectAnnotationUsage( ManyToMany.class ) ) {
			//useful for collection of embedded elements
			columns = buildColumnFromNoAnnotation(
					property.getDirectAnnotationUsage( FractionalSeconds.class ),
					nullability,
					propertyHolder,
					inferredData,
					entityBinder.getSecondaryTables(),
					buildingContext
			);
		}

		if ( nullability == Nullability.FORCED_NOT_NULL ) {
			//force columns to not null
			for ( AnnotatedColumn column : columns.getColumns() ) {
				column.forceNotNull();

View on GitHub (pinned to fad1729dce)

Solutions

  1. Declare at least one @JoinColumn for the @Any property.

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/06e4189964896783. Report an issue: GitHub.