{"record":{"id":"85e7dfc8c644a394","repo":"hibernate/hibernate-orm","slug":"component-type-has-properties-but-the-inst","errorCode":null,"errorMessage":"component type [{}] has {} properties but the instantiator only assigns {} properties. missing properties: {}","messagePattern":"component type \\[(.+?)\\] has (.+?) properties but the instantiator only assigns (.+?) properties\\. missing properties: (.+?)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/Component.java","lineNumber":837,"sourceCode":"\t\t\tif ( instantiatorPropertyNames.length < properties.size() ) {\n\t\t\t\tthrow new MappingException( \"component type [\" + componentClassName + \"] specifies \" + instantiatorPropertyNames.length + \" properties for the instantiator but has \" + properties.size() + \" properties\" );\n\t\t\t}\n\t\t\tfinal HashSet<String> assignedPropertyNames = CollectionHelper.setOfSize( properties.size() );\n\t\t\tfor ( String instantiatorPropertyName : instantiatorPropertyNames ) {\n\t\t\t\tif ( getProperty( instantiatorPropertyName ) == null ) {\n\t\t\t\t\tthrow new MappingException( \"could not find property [\" + instantiatorPropertyName + \"] defined in the @Instantiator withing component [\" + componentClassName + \"]\" );\n\t\t\t\t}\n\t\t\t\tassignedPropertyNames.add( instantiatorPropertyName );\n\t\t\t}\n\t\t\tif ( assignedPropertyNames.size() != properties.size() ) {\n\t\t\t\tfinal ArrayList<String> missingProperties = new ArrayList<>();\n\t\t\t\tfor ( var property : properties ) {\n\t\t\t\t\tfinal String propertyName = property.getName();\n\t\t\t\t\tif ( !assignedPropertyNames.contains( propertyName ) ) {\n\t\t\t\t\t\tmissingProperties.add( propertyName );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new MappingException( \"component type [\" + componentClassName + \"] has \" + properties.size() + \" properties but the instantiator only assigns \" + assignedPropertyNames.size() + \" properties. missing properties: \" + missingProperties );\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean isSorted() {\n\t\treturn originalPropertyOrder != ArrayHelper.EMPTY_INT_ARRAY;\n\t}\n\n\t@Override\n\tpublic int[] sortProperties() {\n\t\treturn sortProperties( false );\n\t}\n\n\tprivate int[] sortProperties(boolean forceRetainOriginalOrder) {\n\t\tif ( originalPropertyOrder != ArrayHelper.EMPTY_INT_ARRAY ) {\n\t\t\treturn originalPropertyOrder;","sourceCodeStart":819,"sourceCodeEnd":855,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/Component.java#L819-L855","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Give every persistent property exactly one constructor parameter - no duplicates, none missing (the message's missing list tells you what to add).","Regenerate the all-args constructor with the IDE instead of editing it by hand.","Switch to a record or remove @Instantiator so Hibernate binds properties canonically."],"exampleFix":"// before - 'last' bound twice, nothing binds it distinctly\n@Instantiator\nName(String first, String last, String lastAgain) { ... }\n\n// after - one parameter per property\n@Instantiator\nName(String first, String last) { ... }","handlingStrategy":"validation","validationCode":"static boolean exactCoverage(Class<?> embeddable, Constructor<?> ctor) {\n    Set<String> fields = Arrays.stream(embeddable.getDeclaredFields())\n            .filter(f -> !Modifier.isStatic(f.getModifiers()))\n            .map(Field::getName)\n            .collect(Collectors.toSet());\n    Set<String> params = Arrays.stream(ctor.getParameters())\n            .map(Parameter::getName)\n            .collect(Collectors.toSet());\n    return fields.equals(params);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate all-args constructors with the IDE after adding or removing embeddable fields.","Use a dedicated @EmbeddableInstantiator implementation when constructor shapes cannot stay 1:1 with properties.","Fail fast: run Metadata building in tests to surface isValid failures early."],"tags":["hibernate","orm","mapping","embeddable","instantiator","constructor"],"backgroundTag":"embeddable-instantiator-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}