This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

mappedBy attribute doubt

 
Joe Harry
Ranch Hand
Posts: 10128
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: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!