Joining two tables Hibernate

Viewed 372

I am working with Spring MVC + Hibernate ( Spring data jpa ).

Here I am not getting how to create a table in Hibernate for the following scenario.

I have two tables :

1) User Details

2) Branch

Now, For every user, there is a field for branch, and that value should be from Branch table.

I have knowledge of OneToOne in hibernate. But it inserts a new entry for users branch field in Branch table. What I want is that, when I save user details in User Table, branch details should be just a reference from Branch table for matching row.

Thank you in advance

3 Answers
Related