Hibernate relationships

Posted by Java developer blog on March 20, 2020

Overview

There are six types of hibernate relationships: one-to-one bidirectional/unidirectional, many-to-many bidirectional/unidirectional and many-to-one bidirectional/unidirectional. In the post, we are going to discuss the difference between different types of hibernate relationships.

The difference between bidirectional and unidirectional relationship

It’s very important to understand the difference between bidirectional and unidirectional relationships.

In the case of a bidirectional relationship, you have access to the other side of the relationship from both sides of the relationship.

On the other hand, in case of a unidirectional relationship you have access to the other side of the relationship only from one side.

We are talking only about Java class or so-called Entity because in the database both bidirectional/unidirectional relationship looks the same.

Conclusion

We have discussed the difference between different types of hibernate relationships. We are going to discuss each pair of relationships in the following posts.