{"record":{"id":"d940cc25936a262d","repo":"hibernate/hibernate-orm","slug":"could-not-find-property-defined-in-the-insta","errorCode":null,"errorMessage":"could not find property [{}] defined in the @Instantiator withing component [{}]","messagePattern":"could not find property \\[(.+?)\\] defined in the @Instantiator withing component \\[(.+?)\\]","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/Component.java","lineNumber":825,"sourceCode":"\n\tpublic void prepareForMappingModel() {\n\t\t// This call will initialize the type properly\n\t\tgetType();\n\t}\n\n\t@Override\n\tpublic boolean isValid(MappingContext mappingContext) throws MappingException {\n\t\tif ( !super.isValid( mappingContext ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tif ( instantiatorPropertyNames != null ) {\n\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","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/Component.java#L807-L843","documentation":"Component#isValid reports that a parameter of the @Instantiator-annotated constructor does not correspond to any persistent property of the embeddable. Hibernate binds constructor parameters to properties by name, so every parameter must match a persistent field name exactly.","triggerScenarios":"Parameter names shortened or abbreviated ('f' for 'first'); a constructor copied from another class; an infrastructure parameter (outer-class reference, flag) added to the annotated constructor; fields renamed without renaming the constructor parameters.","commonSituations":"Hand-written constructors with compact parameter names; classes compiled without -parameters so parameter names are lost; adding boilerplate parameters to a previously working embeddable.","solutions":["Rename the constructor parameter to the exact persistent property name.","Drop parameters that are not persistent properties from the annotated constructor.","Compile with -parameters or use records so parameter names are retained and match fields."],"exampleFix":"// before\n@Instantiator\nName(String f, String l) {\n    this.first = f;\n    this.last = l;\n}\n\n// after\n@Instantiator\nName(String first, String last) {\n    this.first = first;\n    this.last = last;\n}","handlingStrategy":"validation","validationCode":"static List<String> unknownParams(Class<?> embeddable, Constructor<?> ctor) {\n    Set<String> fields = Arrays.stream(embeddable.getDeclaredFields())\n            .map(Field::getName)\n            .collect(Collectors.toSet());\n    return Arrays.stream(ctor.getParameters())\n            .map(Parameter::getName)\n            .filter(n -> !fields.contains(n))\n            .toList();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compile with -parameters so constructor parameter names survive to runtime and match field names.","Use records for embeddables - component names equal field names by construction.","Keep @Instantiator constructors free of non-property parameters (flags, outer references)."],"tags":["hibernate","orm","mapping","embeddable","instantiator","constructor","naming"],"backgroundTag":"embeddable-instantiator-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}