OneToOne
- Anand Nerurkar
- May 1, 2024
- 1 min read
Hibernate
One to one
When we run, answer.answer_id is created in question table ,marked as FKey.
Data is saved
Answer.answer_id is afkey and it is join colmn which we can rename it with joinclumn annotation as below
Abobe is uni direction
To make it bidirection, we need to add question column in answer entity as below
Also add getter /setter for it.
Is is how bidirection is set.
Now e have join column in both table, but we need to maintain in question table only , ignore answer table join column,
So go to answer entity and map question field as below
Th
So join column in answer table is ignored now as below
Comments