{"record":{"id":"c77bb424c507eba1","repo":"hibernate/hibernate-orm","slug":"association-is-mappedby-another-entity-and-c77bb4","errorCode":null,"errorMessage":"Association '{}' is 'mappedBy' another entity and may not specify a '@MapKeyColumn' (use '@MapKey' instead)","messagePattern":"Association '(.+?)' is 'mappedBy' another entity and may not specify a '@MapKeyColumn' \\(use '@MapKey' instead\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java","lineNumber":1214,"sourceCode":"\t\t\t\tthrow new AnnotationException( \"Association '\"\n\t\t\t\t\t\t+ qualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t\t+ \"' is 'mappedBy' another entity and may not specify the '@JoinTable'\" );\n\t\t\t}\n\t\t\tif ( oneToMany ) {\n\t\t\t\tif ( property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) {\n\t\t\t\t\tBOOT_LOGGER.mappedByShouldNotSpecifyMapKeyColumn(\n\t\t\t\t\t\t\tqualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( property.hasDirectAnnotationUsage( OrderColumn.class ) ) {\n\t\t\t\t\tBOOT_LOGGER.mappedByShouldNotSpecifyOrderColumn(\n\t\t\t\t\t\t\tqualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ( property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) {\n\t\t\t\t\tthrow new AnnotationException( \"Association '\"\n\t\t\t\t\t\t\t+ qualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t\t\t+ \"' is 'mappedBy' another entity and may not specify a '@MapKeyColumn'\"\n\t\t\t\t\t\t\t+ \" (use '@MapKey' instead)\" );\n\t\t\t\t}\n\t\t\t\tif ( property.hasDirectAnnotationUsage( OrderColumn.class ) ) {\n\t\t\t\t\tthrow new AnnotationException( \"Association '\"\n\t\t\t\t\t\t\t+ qualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t\t\t+ \"' is 'mappedBy' another entity and may not specify an '@OrderColumn'\"\n\t\t\t\t\t\t\t+ \" (use '@OrderBy' instead)\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if ( oneToMany\n\t\t\t\t&& property.hasDirectAnnotationUsage( OnDelete.class )\n\t\t\t\t&& !hasExplicitJoinColumn() ) {\n\t\t\tthrow new AnnotationException( \"Unidirectional '@OneToMany' association '\"\n\t\t\t\t\t+ qualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t+ \"' is annotated '@OnDelete' and must explicitly specify a '@JoinColumn'\" );","sourceCodeStart":1196,"sourceCodeEnd":1232,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java#L1196-L1232","documentation":"Error \"Association '{}' is 'mappedBy' another entity and may not specify a '@MapKeyColumn' (use '@MapKey' instead)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An association declares 'mappedBy' naming a property that does not exist, has the wrong type, or is not the owning side on the target entity.","commonSituations":"Bidirectional associations where mappedBy is misspelled, both sides claim ownership, or the target entity was refactored without updating the mapping.","solutions":["Remove @MapKeyColumn from the mappedBy side and use @MapKey instead, as instructed."],"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"}