{"record":{"id":"3f2924ecbac44eab","repo":"hibernate/hibernate-orm","slug":"both-sides-of-the-bidirectional-association-a","errorCode":null,"errorMessage":"Both sides of the bidirectional association '\" + associatedClass.getEntityName() + \".\" + mappedByProperty + \"' specify 'mappedBy'","messagePattern":"Both sides of the bidirectional association '\" \\+ associatedClass\\.getEntityName\\(\\) \\+ \"\\.\" \\+ mappedByProperty \\+ \"' specify 'mappedBy'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java","lineNumber":860,"sourceCode":"\t\t\tAnnotatedJoinColumns joinColumns,\n\t\t\tSimpleValue value,\n\t\t\tPersistentClass associatedClass,\n\t\t\tString mappedByProperty) {\n\t\tfinal var firstColumn = joinColumns.getJoinColumns().get(0);\n\t\tfor ( var selectable: mappedByColumns( associatedClass, mappedByProperty ) ) {\n\t\t\tif ( selectable instanceof Column column ) {\n\t\t\t\tfirstColumn.overrideFromReferencedColumnIfNecessary( column );\n\t\t\t}\n\t\t\tfirstColumn.linkValueUsingCopy( selectable, value );\n\t\t}\n\t}\n\n\tprivate static List<Selectable> mappedByColumns(PersistentClass associatedClass, String mappedByProperty) {\n\t\tfinal var value = associatedClass.getRecursiveProperty( mappedByProperty ).getValue();\n\t\tif ( value instanceof Collection collection ) {\n\t\t\tfinal var element = collection.getElement();\n\t\t\tif ( element == null ) {\n\t\t\t\tthrow new AnnotationException( \"Both sides of the bidirectional association '\"\n\t\t\t\t\t\t+ associatedClass.getEntityName() + \".\" + mappedByProperty + \"' specify 'mappedBy'\" );\n\t\t\t}\n\t\t\treturn element.getSelectables();\n\t\t}\n\t\telse if ( value instanceof Any any ) {\n\t\t\treturn any.getKeyDescriptor().getSelectables();\n\t\t}\n\t\telse {\n\t\t\treturn value.getSelectables();\n\t\t}\n\t}\n\n\tpublic static void linkJoinColumnWithValueOverridingNameIfImplicit(\n\t\t\tPersistentClass referencedEntity,\n\t\t\tValue value,\n\t\t\tAnnotatedJoinColumns joinColumns,\n\t\t\tSimpleValue simpleValue) {\n\t\tfinal var valueColumns = value.getColumns();","sourceCodeStart":842,"sourceCodeEnd":878,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java#L842-L878","documentation":"Error \"Both sides of the bidirectional association '\" + associatedClass.getEntityName() + \".\" + mappedByProperty + \"' specify 'mappedBy'\" 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 mappedBy from one side of the bidirectional association so only one side is unowned."],"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"}