Relational Associations Tutorial Hibernate

Relational Associations Tutorial Hibernate


Hibernate Relational Associations Tutorial

Two important features of Hibernate are Inheritance (Hierarchical) Mapping (supported by table-per-subclass etc.) and Relational Associations (supported by one-to-many etc.) The first one is discussed earlier and now let us go for the second one.

In database terminology, an association denotes a relationship between two tables. This tutorial explains the way how Hibernate writes Java bean classes to implement this relation.

Some table associations require an extra join table with primary and foreign keys which Hibernate also supports. As in SQL, it is not a good idea to have nullable foreign keys and this is not a requirement for Hibernate.

The associations may be unidirectional or bidirectional.

The 4 associations Hibernate supports are

1. One to One
2. One to Many
3. Many to One
4. Many to Many

More than writing association classes, it requires a good logic to choose which association suits to the application.

Leave a Reply

Your email address will not be published. Required fields are marked *