• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mappedBy attribute doubt

 
Joe Harry
Ranch Hand
Posts: 10112
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly does the mappedBy acheives?? Isn't it enough that I just use the @JoinColumn Annotation? Why do I need a mappedBy when I have a Bi-Directional association?
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jothi Shankar Kumar Sankararaj:
What exactly does the mappedBy acheives?? Isn't it enough that I just use the @JoinColumn Annotation? Why do I need a mappedBy when I have a Bi-Directional association?


mappedBy specifies the relationship is bi-directional. If you do not specify the mappedBy the relationships are still valid but these are independent one directional two separate relationships each one is owning side of the relationship in these two relationship.

At the Object model level this may not have importance, but at relationship level it decide that the foregion keys are alway store in the table which is related to the Object which does not have mappedBy attribute.

Thanks
 
Joe Harry
Ranch Hand
Posts: 10112
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic