hibernate/hibernate-orm · error · AnnotationException

Collection '<path>' is an association with no join table and

Error message

Collection '<path>' is an association with no join table and may not have a 'WhereJoinTable'

What it means

Error "Collection '<path>' is an association with no join table and may not have a 'WhereJoinTable'" thrown in hibernate/hibernate-orm.

Source

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

			collection.setManyToManyWhere( whereClause );
		}
		else {
			// A one-to-many association does not have an association (join) table.
			// Collection#setWhere is used to set the "where" clause that applies to the collection table
			// (which is the associated entity table for a one-to-many association).
			collection.setWhere( whereClause );
		}

		final String whereJoinTableClause = getWhereJoinTableClause();
		if ( isNotBlank( whereJoinTableClause ) ) {
			if ( hasAssociationTable ) {
				// This is a many-to-many association.
				// Collection#setWhere is used to set the "where" clause that applies to the collection table
				// (which is the join table for a many-to-many association).
				collection.setWhere( whereJoinTableClause );
			}
			else {
				throw new AnnotationException(
						"Collection '" + qualify( propertyHolder.getPath(), propertyName )
								+ "' is an association with no join table and may not have a 'WhereJoinTable'"
				);
			}
		}
	}

	private String getWhereJoinTableClause() {
		final var joinTableRestriction = property.getDirectAnnotationUsage( SQLJoinTableRestriction.class );
		return joinTableRestriction != null ? joinTableRestriction.value() : null;
	}

	private String getWhereClause() {
		// There are 2 possible sources of "where" clauses that apply to the associated entity table:
		// 1) from the associated entity mapping; i.e., @Entity @Where(clause="...")
		//    (ignored if useEntityWhereClauseForCollections == false)
		// 2) from the collection mapping;
		//    for one-to-many, e.g., @OneToMany @JoinColumn @Where(clause="...") public Set<Rating> getRatings();

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove the @WhereJoinTable from the association, since it has no join table.
  2. Or configure a join table for the association if the where-join-table clause is needed.

When it happens

Trigger: A @Filter/@FilterJoinTable usage references an undefined filter or has no usable condition.

Common situations: @Filter used without a matching @FilterDef, a misspelled filter name, or neither the usage nor the FilterDef supplying a default condition.


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