{"record":{"id":"fdee3fe396786df9","repo":"hibernate/hibernate-orm","slug":"association-is-mappedby-another-entity-and-fdee3f","errorCode":null,"errorMessage":"Association '{}' is 'mappedBy' another entity and may not specify an '@OrderColumn' (use '@OrderBy' instead)","messagePattern":"Association '(.+?)' is 'mappedBy' another entity and may not specify an '@OrderColumn' \\(use '@OrderBy' instead\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java","lineNumber":1220,"sourceCode":"\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'\" );\n\t\t}\n\t}\n\n\tprivate boolean hasExplicitJoinColumn() {\n\t\treturn property.hasDirectAnnotationUsage( JoinColumn.class )\n\t\t\t|| property.hasDirectAnnotationUsage( JoinColumns.class )","sourceCodeStart":1202,"sourceCodeEnd":1238,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java#L1202-L1238","documentation":"Error \"Association '{}' is 'mappedBy' another entity and may not specify an '@OrderColumn' (use '@OrderBy' 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 @OrderColumn from the mappedBy side and use @OrderBy instead."],"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"}