hibernate/hibernate-orm · error · AnnotationException

Multiple '@FilterDef' annotations define a filter named '${n

Error message

Multiple '@FilterDef' annotations define a filter named '${name}'

What it means

Error "Multiple '@FilterDef' annotations define a filter named '${name}'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java:48

import static org.hibernate.boot.BootLogging.BOOT_LOGGER;
import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty;

/**
 * @author Gavin King
 */
public class FilterDefBinder {

	public static void bindFilterDefs(AnnotationTarget annotatedElement, MetadataBuildingContext context) {
		final var modelsContext = context.getBootstrapContext().getModelsContext();
		annotatedElement.forEachAnnotationUsage( FilterDef.class, modelsContext, (usage) -> {
			bindFilterDef( usage, context );
		} );
	}

	public static void bindFilterDef(FilterDef filterDef, MetadataBuildingContext context) {
		final String name = filterDef.name();
		if ( context.getMetadataCollector().getFilterDefinition( name ) != null ) {
			throw new AnnotationException( "Multiple '@FilterDef' annotations define a filter named '" + name + "'" );
		}

		final Map<String, JdbcMapping> paramJdbcMappings;
		final Map<String, ManagedBean<? extends Supplier<?>>> parameterResolvers;
		final var explicitParameters = filterDef.parameters();
		if ( isEmpty( explicitParameters ) ) {
			paramJdbcMappings = emptyMap();
			parameterResolvers = emptyMap();
		}
		else {
			paramJdbcMappings = new HashMap<>();
			parameterResolvers = new HashMap<>();
			for ( var explicitParameter : explicitParameters ) {
				final String parameterName = explicitParameter.name();
				final var typeClassDetails = explicitParameter.type();
				final var jdbcMapping = resolveFilterParamType( typeClassDetails, context );
				if ( jdbcMapping == null ) {
					throw new MappingException(

View on GitHub (pinned to fad1729dce)

Solutions

  1. Rename one of the @FilterDef annotations so filter names are unique.

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/8516aacb46f73845. Report an issue: GitHub.