hibernate/hibernate-orm · error · MappingException

component type [{}] has {} properties but the instantiator o

Error message

component type [{}] has {} properties but the instantiator only assigns {} properties. missing properties: {}

What it means

Component#isValid detects that the set of properties the @Instantiator-annotated constructor assigns does not equal the embeddable's property set: after deduplication, some property is never bound. The message lists the properties the instantiator fails to assign.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/mapping/Component.java:837

			if ( instantiatorPropertyNames.length < properties.size() ) {
				throw new MappingException( "component type [" + componentClassName + "] specifies " + instantiatorPropertyNames.length + " properties for the instantiator but has " + properties.size() + " properties" );
			}
			final HashSet<String> assignedPropertyNames = CollectionHelper.setOfSize( properties.size() );
			for ( String instantiatorPropertyName : instantiatorPropertyNames ) {
				if ( getProperty( instantiatorPropertyName ) == null ) {
					throw new MappingException( "could not find property [" + instantiatorPropertyName + "] defined in the @Instantiator withing component [" + componentClassName + "]" );
				}
				assignedPropertyNames.add( instantiatorPropertyName );
			}
			if ( assignedPropertyNames.size() != properties.size() ) {
				final ArrayList<String> missingProperties = new ArrayList<>();
				for ( var property : properties ) {
					final String propertyName = property.getName();
					if ( !assignedPropertyNames.contains( propertyName ) ) {
						missingProperties.add( propertyName );
					}
				}
				throw new MappingException( "component type [" + componentClassName + "] has " + properties.size() + " properties but the instantiator only assigns " + assignedPropertyNames.size() + " properties. missing properties: " + missingProperties );
			}
		}
		return true;
	}

	@Override
	public boolean isSorted() {
		return originalPropertyOrder != ArrayHelper.EMPTY_INT_ARRAY;
	}

	@Override
	public int[] sortProperties() {
		return sortProperties( false );
	}

	private int[] sortProperties(boolean forceRetainOriginalOrder) {
		if ( originalPropertyOrder != ArrayHelper.EMPTY_INT_ARRAY ) {
			return originalPropertyOrder;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Give every persistent property exactly one constructor parameter - no duplicates, none missing (the message's missing list tells you what to add).
  2. Regenerate the all-args constructor with the IDE instead of editing it by hand.
  3. Switch to a record or remove @Instantiator so Hibernate binds properties canonically.

Example fix

// before - 'last' bound twice, nothing binds it distinctly
@Instantiator
Name(String first, String last, String lastAgain) { ... }

// after - one parameter per property
@Instantiator
Name(String first, String last) { ... }
Defensive patterns

Strategy: validation

Validate before calling

static boolean exactCoverage(Class<?> embeddable, Constructor<?> ctor) {
    Set<String> fields = Arrays.stream(embeddable.getDeclaredFields())
            .filter(f -> !Modifier.isStatic(f.getModifiers()))
            .map(Field::getName)
            .collect(Collectors.toSet());
    Set<String> params = Arrays.stream(ctor.getParameters())
            .map(Parameter::getName)
            .collect(Collectors.toSet());
    return fields.equals(params);
}

Prevention

When it happens

Trigger: Constructor parameters resolving to the same property (duplicate binding) while another property has no parameter; extra parameters duplicating an existing property; a synthetic or outer-instance parameter taking a slot; property sets changed by sorting or subclassing.

Common situations: Overloaded or generated constructors where a parameter was duplicated by copy-paste; inner non-static classes whose implicit outer reference appears as a parameter; hand-maintained constructors drifting from the field list.

Related errors


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