Despite the fact that my question is specifically formulated regarding how Entity relationships are displayed in a Play framework that uses Hibernate, I'm sure this is a general concept.
When we have a one-to-many relationship, we are always asked to indicate the side of the owner.
So, for example, if we had a one-to-many relationship between Person and PhoneNumber, we will write such code.
@Entity class Person { @OneToMany(mappedBy="person") public Set<PhoneNumber> phoneNumbers; } @Entity class PhoneNumber { @ManyToOne public Person person; }
In the code above, your own organization is PhoneNumber. What are the pros and cons of any of the property parties?
I understand that if the owner is PhoneNUmber, then the presented relationship is ManyToOne, which will not lead to a connection table, whereas when the owner is Person, the designated connection will be OneToMany, in which case a relationship table will be created.
Is this the main reason for determining the owner or are there other reasons?
Update: I just realized that this thread provides part of the answer, but I hope there may be other points.
Parag
source share