I have a situation where few tables (TableA & TableB) have one-to-one relationship with a same table (TableC). TableA and TableB are unrelated. I have designed the tables as below.
TableA
- key
- something
- c_ref_key
TableB
- key
- something
- c_ref_key
TableC
- key
- something
When I generate JPA entity from this database using hibernate reverse-engineering, it create many-to-one relation in TableA and TableB for TableC. Normally to create one-to-one relationship I would have TableA primary key as primary key of TableC but since I have other tables (TableB) which also have one-to-one relationship with TableC , I cant do that. Hence I had to use TableC's foreign key in TableA and TableB (which resulted in many-to-one relationship in JPA). Is there any other way to design to keep the relationships one-to-one ? or atleast in generated JPA entities can have one-to-one relationship ?