I am trying to create relationships between different persons but couldn’t find a way on how to do it using JPA. Below is the model given to support the requirement:
Person table:
Id FirstName LastName
1 John Heller
2 Joseph Heller
3 Andrew Heller
4 Steven Heller
Person_Relationship table
Id Person1 Person2 Relationship
1 1 2 Parent
2 2 1 Child
3 1 3 Sibling
4 3 1 Sibling
5 4 1 Secretary
Can someone please share your experience if you have ever implemented the above using Hibernate as JPA provider.
The easiest way is to use a OneToMany association between a
Personentity and aRelationShipentity, each entity mapping the associated table: