Even though my question is worded specifically to the way Entity relationships are depicted in the Play framework, which uses Hibernate, I am sure this is a general concept.
When we have a one-to-many relationship, we are always asked to specify the owning side.
So, for example if we had a one-to-many relationship between Person and PhoneNumber, we would write code like this.
@Entity
class Person {
@OneToMany(mappedBy="person")
public Set<PhoneNumber> phoneNumbers;
}
@Entity
class PhoneNumber {
@ManyToOne
public Person person;
}
In the code above, the owning Entity is PhoneNumber. What are the pros and cons of either side being the owning entity ?
I realize when the owning entity is PhoneNUmber, the relationship represented is ManyToOne, which will not result in a join table, whereas when the owning side is Person, the relationship depicted would be OneToMany, in which case a relationship table will be created.
Is this the main reason for determining the owning side, or are there other reasons as well ?
Update: I just realized that this thread provides part of the answer, but I am hoping there may be other points as well.