WS WhereIsStuff
Tutorial Guides
Log In
Sign Up

Advertisement

Google Ad Slot: content-top

HB Relationship Mappings


Hibernate provides various relationship mappings to define associations between entities using annotations. These relationships correspond to SQL JOIN operations.

Types of Relationship Mappings:

Relationship Type

Description

Example

One-to-One (@OneToOne)

One entity has exactly one related entity.

A User has oneProfile.

One-to-Many (@OneToMany)

One entity has multiple related entities.

A Department has manyEmployees.

Many-to-One (@ManyToOne)

Many entities are related to one entity.

Many Employees belong to oneDepartment.

Many-to-Many (@ManyToMany)

Many entities are related to many entities.

Many Students enroll in manyCourses.