This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
Joined: May 15, 2005
But why always is the many side of one-to many /many to one bidirectinal relationship must be the owning side?
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
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 ]