Hibernate One to One Unidirectional Shared Primary Key

You may also like...

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Michael Kay Recent comment authors
  Subscribe  
newest oldest
Notify of
Michael Kay
Guest
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.