hibernate/hibernate-orm · error · AnnotationException

Association '<role>' is an unowned collection and may not be

Error message

Association '<role>' is an unowned collection and may not be annotated '@Check'

What it means

Error "Association '<role>' is an unowned collection and may not be annotated '@Check'" thrown in hibernate/hibernate-orm.

Source

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

						.getValue();
		final var table =
				mappedByPropertyValue instanceof Collection collectionProperty
						// this is a collection on the other side
						? collectionProperty.getCollectionTable()
						// this is a ToOne with a @JoinTable or a regular property
						: mappedByPropertyValue.getTable();
		collection.setCollectionTable( table );

		processSoftDeletes();
		processTemporal();
		processAudited();
		checkCheckAnnotation();
	}

	private void checkCheckAnnotation() {
		if ( property.hasDirectAnnotationUsage( Checks.class )
			|| property.hasDirectAnnotationUsage( Check.class ) ) {
			throw new AnnotationException( "Association '" + safeCollectionRole()
					+ " is an unowned collection and may not be annotated '@Check'" );
		}
	}

	private void detectManyToManyProblems(
			TypeDetails elementType,
			boolean isCollectionOfEntities,
			boolean isManyToAny) {

		if ( !isCollectionOfEntities) {
			if ( property.hasDirectAnnotationUsage( ManyToMany.class )
					|| property.hasDirectAnnotationUsage( OneToMany.class ) ) {
				throw new AnnotationException( "Association '" + safeCollectionRole() + "'"
						+ targetEntityMessage( elementType ) );
			}
			else if (isManyToAny) {
				final var joinTable = propertyHolder.getJoinTable( property );
				if ( joinTable == null ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove @Check from the unowned (mappedBy) collection side; place it on the owning side instead.

When it happens

Trigger: A collection mapping uses an annotation or annotation combination that Hibernate forbids for collections.

Common situations: Collections carrying conflicting ordering/sorting (@Sort* vs @OrderBy/@OrderColumn), misplaced @JoinColumn, or annotations only valid for single-valued associations.


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