wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 9345
    
    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: 9345
    
    2

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mappedBy attribute doubt
 
Similar Threads
what us mean mappedBy="item" ?
MDB on glassfish without mappedBy
Entities association relationship defaults - Choose Correct statement
JPA2.0 CascadeType.ALL doesn't cascade persist
@ManayToMany