hibernate/hibernate-orm · error · AnnotationException

Collection ' ' has a '@ ' with no 'condition' and no…

Error message

Collection '<path>' has a '@<annotationSimpleName>' with no 'condition' and no default condition was given by the '@FilterDef' named '<name>'

What it means

Filter condition fallback failure: a collection-level @Filter specifies no condition and the @FilterDef with that name also defines no default condition. Neither source supplied the SQL fragment needed to activate the filter.

Solutions

  1. Add an explicit condition to the filter annotation, or give the @FilterDef a defaultCondition.
Defensive patterns

Strategy: fallback

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/7740bcc6afac5d3f. Report an issue: GitHub.

Appendix: source

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

	}

	private String getFilterCondition(Filter filter) {
		final String condition = filter.condition();
		return condition.isBlank()
				? getDefaultFilterCondition( filter.name(), filter )
				: condition;
	}

	private String getDefaultFilterCondition(String name, Annotation annotation) {
		final var definition = getMetadataCollector().getFilterDefinition( name );
		if ( definition == null ) {
			throw new AnnotationException( "Collection '" + qualify( propertyHolder.getPath(), propertyName )
					+ "' has a '@" + annotation.annotationType().getSimpleName()
					+ "' for an undefined filter named '" + name + "'" );
		}
		final String defaultCondition = definition.getDefaultFilterCondition();
		if ( isBlank( defaultCondition ) ) {
			throw new AnnotationException( "Collection '" + qualify( propertyHolder.getPath(), propertyName ) +
					"' has a '@"  + annotation.annotationType().getSimpleName()
					+ "' with no 'condition' and no default condition was given by the '@FilterDef' named '"
					+ name + "'" );
		}
		return defaultCondition;
	}

	private void setCache(Cache cache) {
		if ( cache != null ) {
			cacheRegionName = nullIfEmpty( cache.region() );
			cacheConcurrencyStrategy = EntityBinder.getCacheConcurrencyStrategy( cache.usage() );
		}
		else {
			cacheConcurrencyStrategy = null;
			cacheRegionName = null;
		}
	}

View on GitHub (pinned to fad1729dce)