• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@mappedBy

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?

mallika
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Thanks,
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Owner side of the relationship is the one which contains foreign key in db table
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic