hibernate-006: Unidirectional One-to-Many and Many-to-One in Hibernate (Department ↔ Employee)
Unidirectional One-to-Many and Many-to-One using Department and Employee Tables I'll show you both unidirectional approaches: Unidirectional @OneToMany → The Department entity knows about Employee, but Employee does NOT know about Department. Unidirectional @ManyToOne → The Employee entity knows about Department, but Department does NOT know about Employee. 1️⃣ Unidirectional @OneToMany (Not Recommended - Uses Extra Join Table)

Unidirectional One-to-Many and Many-to-One using Department and Employee Tables
I'll show you both unidirectional approaches:
-
Unidirectional
@OneToMany
→ TheDepartment
entity knows aboutEmployee
, butEmployee
does NOT know aboutDepartment
. -
Unidirectional
@ManyToOne
→ TheEmployee
entity knows aboutDepartment
, butDepartment
does NOT know aboutEmployee
.
1️⃣ Unidirectional @OneToMany
(Not Recommended - Uses Extra Join Table)