{"record":{"id":"08dd22a3eb78113f","repo":"hibernate/hibernate-orm","slug":"property-path-belongs-to-an-idclass-but-has","errorCode":null,"errorMessage":"Property '<path>' belongs to an '@IdClass' but has no matching property in entity class '<propertyType>' (every property of the '@IdClass' must have a corresponding persistent property in the '@Entity' class)","messagePattern":"Property '<path>' belongs to an '@IdClass' but has no matching property in entity class '<propertyType>' \\(every property of the '@IdClass' must have a corresponding persistent property in the '@Entity' class\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java","lineNumber":946,"sourceCode":"\t\tfinal Map<String, PropertyData> baseClassElementsByName = new HashMap<>();\n\t\tfor ( var element : baseClassElements ) {\n\t\t\tbaseClassElementsByName.put( element.getPropertyName(), element );\n\t\t}\n\t\tfor ( int i = 0; i < classElements.size(); i++ ) {\n\t\t\tfinal var idClassPropertyData = classElements.get( i );\n\t\t\tfinal var entityPropertyData = baseClassElementsByName.get( idClassPropertyData.getPropertyName() );\n\t\t\tif ( !propertyHolder.isInIdClass()\n\t\t\t\t\t|| checkIdProperty( propertyHolder, baseInferredData, entityPropertyData, idClassPropertyData ) ) {\n\t\t\t\tclassElements.set( i, entityPropertyData );  //this works since they are in the same order\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static boolean checkIdProperty(\n\t\t\tPropertyHolder propertyHolder, PropertyData baseInferredData,\n\t\t\tPropertyData entityPropertyData, PropertyData idClassPropertyData) {\n\t\tif ( entityPropertyData == null ) {\n\t\t\tthrow new AnnotationException(\n\t\t\t\t\t\"Property '\" + getPath( propertyHolder, idClassPropertyData )\n\t\t\t\t\t+ \"' belongs to an '@IdClass' but has no matching property in entity class '\"\n\t\t\t\t\t+ baseInferredData.getPropertyType().getName()\n\t\t\t\t\t+ \"' (every property of the '@IdClass' must have a corresponding persistent property in the '@Entity' class)\"\n\t\t\t);\n\t\t}\n\t\telse if ( deferIdProperty( entityPropertyData, idClassPropertyData ) ) {\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tfinal String idPropertyTypeName = idClassPropertyData.getTypeName();\n\t\t\tfinal String entityPropertyTypeName = entityPropertyData.getTypeName();\n\t\t\tif ( !hasCompatibleType( idPropertyTypeName, entityPropertyTypeName ) ) {\n\t\t\t\tthrow new AnnotationException(\n\t\t\t\t\t\t\"Property '\" + idClassPropertyData.getPropertyName()\n\t\t\t\t\t\t+ \"' in @IdClass '\" + idClassPropertyData.getDeclaringClass().getName()\n\t\t\t\t\t\t+ \"' doesn't match type in entity class '\" + baseInferredData.getPropertyType().getName()\n\t\t\t\t\t\t+ \"' (expected '\" + entityPropertyTypeName + \"' but was '\" + idPropertyTypeName + \"')\"","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java#L928-L964","documentation":"Error \"Property '<path>' belongs to an '@IdClass' but has no matching property in entity class '<propertyType>' (every property of the '@IdClass' must have a corresponding persistent property in the '@Entity' class)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A composite identifier mapping (@IdClass/@EmbeddedId/@MapsId) does not match the entity's persistent properties.","commonSituations":"Composite primary keys where the id class properties, their types, or @MapsId values drift out of sync with the entity, or an embeddable with inheritance is reused as an id.","solutions":["Add a matching persistent property to the entity class for every property of the @IdClass.","Or remove the unmatched property from the @IdClass."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}