OneToOne « Key « JPA Q&A

1. OneToOne Using Foreign Key as a Primary Key + Hibernate

We have Two Objects:

 Class Person {
   Long id;

Class MedicalHistory {
  Person person;
How should we enable the Person object as the primary key for the MedicalHistory object ...

2. OneToOne between two tables with shared primary key

I'm trying to set up the following tables using JPA/Hibernate:


userid - PK


userid - PK, FK(user)
There may be many users and every user may have max one validation code or none. Here's ...