Search code examples
hibernatejpaone-to-manyhibernate-mappingjoin

Hibernate: which table is owner table in one-to-many unidirectional relationship using join table


How do we decide which table is the owner table in a unidirectional one-to-many relationship using join table?

What role does it play?

Hibernate documentation talks about owner table name and other side table name.

I am using Hibernate with JPA annotations.


Solution

  • If the association is unidirectional, it means only one entity is in charge of the aforementioned relationship.

    So, for unidirectional associations the side containing the association mapping is the one controlling it.

    For bidirectional associations, you have to choose which sides to control the association.

    For performance reasons, it's usually the @ManyToOne side.