• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Owning Side?

 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Customer Table
ID
NAME,

PHONE Table
PHONE_ID
NUMBER
CUST_ID (Foregin Key)

In this case, would the phone be the owning side?

Secondly, is @JoinColumn used only in the owning side?
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The owning side of an entity relationship is the side where the primary key is stored in the database. Usually you can identify the reverse side of the owning side with the annotation attribute "mappedBy".

With @ManyToOne and @OneToMany relationships it's always the "Many" side.

Marco
 
Nikhil Jain
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But why always is the many side of one-to many /many to one bidirectinal relationship must be the owning side?
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I read somewhere that this was a little weakness of the current versions of the JPA. And i read that there were some considerations if this could be changed in future versions. But unfortunately I don't know if this already has changed or will change some day.

Technically it's only natural to keep a simple foreign key on the many side in such relationships if you don't want to use unnecessary join tables. Anyway it has an impact on how you have to make cascaded updates to this relations. If you want your "One" side to be the owning side of your conceptual data model cascaded updates aren't automatically propagated to the "Many" side.

Perhaps someone with deeper understanding and insight in database design and the JPA may enlighten us
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In unidirectional one to many relationship(using jointable) one-side has to be the owning side since many-side does not have the reference to one-side entity. Isnt it??
 
Nikhil Jain
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting very confused. Are there any good notes on explanation on it?
 
Tushar Roy
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go through the persistence specs. It will give you the best idea.
[ March 30, 2008: Message edited by: Tushar Roy ]
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a nice presentation of the Java persistence API and EJB 3.0 in general. On page 12 is a short explanation of relationships and the owning side.

O'Reilly's "Enterprise JavaBeans 3.0" also covers JPA detailed enough.

What i personally find most confusing is the fact that your programming and data model of your application doesn't necessarily have to be the same as the data model actually persisted in the database. So it's often easier for me just to design and program what i really need and don't think too much about database concerns.

Marco
[ March 30, 2008: Message edited by: Marco Ehrentreich ]
 
Nikhil Jain
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
seems to be a good presentation. Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic