top of page

OneToOne

  • Writer: Anand Nerurkar
    Anand Nerurkar
  • May 1, 2024
  • 1 min read

Hibernate

One to one


ree

 

ree
ree

ree
ree


When we run, answer.answer_id is created in question table ,marked as FKey.

 

ree

Data is saved

 

ree

 

Answer.answer_id is afkey and it is join colmn which we can rename it with joinclumn annotation as below



ree

 

ree

 

ree

Abobe is uni direction

 

To make it bidirection, we need to add question column in answer entity as below

ree

 

Also add getter /setter for it.


 

ree

Is is how bidirection is set.

 

ree

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

ree

Th

So join column in answer table is ignored now as below

ree

 

ree

 

 

 

 

 
 
 

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
  • Facebook
  • Twitter
  • LinkedIn

©2024 by AeeroTech. Proudly created with Wix.com

bottom of page