Hibernate One to One Unidirectional Shared Primary Key

You may also like...

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Michael Kay Recent comment authors
newest oldest
Notify of
Michael Kay
Michael Kay

This looked exactly like what I wanted but I am unsure this works as is. This relies upon the DB keeping the two keys of Dog and Collar in sync. If I create a Collar without a Dog, the next inserted Primary Keys are out of sync and no longer reference each other.

For this being useful wouldn’t you want the foreign key to be the other way round? A Dog can exist without a Collar but not the other way?

Great writing on the example though, just not sure this works.