{"record":{"id":"0155cf3f226569f6","repo":"hibernate/hibernate-orm","slug":"missing-value-in-mapsid-annotation-of-associa","errorCode":null,"errorMessage":"Missing 'value' in '@MapsId' annotation of association '<propertyName>' of entity '<entityName>' with composite identifier type ('@MapsId' must specify a property of the '@EmbeddedId' class which has the foreign key of '<referencedEntityName>')","messagePattern":"Missing 'value' in '@MapsId' annotation of association '<propertyName>' of entity '<entityName>' with composite identifier type \\('@MapsId' must specify a property of the '@EmbeddedId' class which has the foreign key of '<referencedEntityName>'\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java","lineNumber":1258,"sourceCode":"\t\t\t\t\t\treferencedProperty\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tprivate Component getReferencedComponent(PersistentClass referencedPersistentClass) {\n\t\t\tif ( referencedPersistentClass == null ) {\n\t\t\t\t// TODO: much better error message if this is something that can really happen!\n\t\t\t\tthrow new AnnotationException( \"Unknown entity name '\" + referencedEntityName + \"'\");\n\t\t\t}\n\t\t\tif ( referencedPersistentClass.getIdentifier() instanceof Component id ) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// The entity with the @MapsId annotation has a composite\n\t\t\t\t// id type, but the referenced entity has a basic-typed id.\n\t\t\t\t// Therefore, the @MapsId annotation should have specified\n\t\t\t\t// a property of the composite id that has the foreign key\n\t\t\t\tthrow new AnnotationException(\n\t\t\t\t\t\t\"Missing 'value' in '@MapsId' annotation of association '\" + propertyName\n\t\t\t\t\t\t+ \"' of entity '\" + embeddable.getOwner().getEntityName()\n\t\t\t\t\t\t+ \"' with composite identifier type\"\n\t\t\t\t\t\t+ \" ('@MapsId' must specify a property of the '@EmbeddedId' class which has the foreign key of '\"\n\t\t\t\t\t\t+ referencedEntityName + \"')\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tprivate Property createComponentProperty(\n\t\t\t\tboolean isExplicitReference,\n\t\t\t\tMap<String, AnnotatedJoinColumn> columnByReferencedName,\n\t\t\t\tMutableInteger index,\n\t\t\t\tProperty referencedProperty ) {\n\t\t\tfinal var property = new Property();\n\t\t\tproperty.setName( referencedProperty.getName() );\n\t\t\t//FIXME set optional?\n\t\t\t//property.setOptional( property.isOptional() );","sourceCodeStart":1240,"sourceCodeEnd":1276,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java#L1240-L1276","documentation":"Error \"Missing 'value' in '@MapsId' annotation of association '<propertyName>' of entity '<entityName>' with composite identifier type ('@MapsId' must specify a property of the '@EmbeddedId' class which has the foreign key of '<referencedEntityName>')\" 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":["Set @MapsId(value=...) to the property of the @EmbeddedId class holding the foreign key."],"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"}