This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes @mappedBy 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" Watch "@mappedBy" New topic


mallika shah
Ranch Hand

Joined: May 11, 2006
Posts: 164
Hello ,

A question says: A Flight bean and a Reservation bean have a @OneToMany relationship.
And asks which code represents the correct relationship.

How would a person know which is the owner side and which is the inverse side of the relationship to apply the @mappedBy attribute ?

Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
I'm assuming this relationship is bidirectional because the mappedBy annotation was mentioned. This attribute pertains to the owning side of the relationship.

You can read the section on Entity Relationships from the book Enterprise JavaBeans 3.0 (5th Edition) for more details.

[ January 02, 2008: Message edited by: Michael Guevara ]

SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
waleed zedan

Joined: Apr 12, 2004
Posts: 10
Persistence specification:

The inverse side of a bidirectional relationship must refer to its owning side by use of the
mappedBy element of the OneToOne, OneToMany, or ManyToMany annotation. The
mappedBy element designates the property or field in the entity that is the owner of the relationship.

So , @mappedby should be placed on the inverse side not the owning side


Waleed Zedan<br />SCJP 1.4
Pawel Dolega

Joined: May 23, 2006
Posts: 5
Owner side of the relationship is the one which contains foreign key in db table
jQuery in Action, 2nd edition
subject: @mappedBy
Similar Threads
possible error in SCBCD prep question?
Hibernate and extra insert
mappedBy attribute doubt
Owner of the RelationShip