Hibernate One to One Unidirectional Shared Primary Key

You may also like...

  • 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.