This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes mappedBy attribute doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "mappedBy attribute doubt" Watch "mappedBy attribute doubt" New topic
Author

mappedBy attribute doubt

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9351
    
    2

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?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
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


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9351
    
    2

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mappedBy attribute doubt