Hibernate One to One Unidirectional Shared Primary Key

You may also like...

Subscribe
Notify of
guest
1 Comment
Oldest
Newest
Inline Feedbacks
View all comments
Michael Kay
Michael Kay
November 28, 2016 12:45

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.

1
0
Would love your thoughts, please comment.x
()
x