Hibernate One to One Annotation based App with shared primary key
Important Points
- Author class is an owning side of association (Unidirectional associations doesn’t have inverse side). Owning side is determined by existence of primary key.
- Unidirectional association implies existence of reference just in one class (In our case it’s @OneToONe annotation in Author class).
- The @PrimaryKeyJoinColumn annotation specifies the primary key column that is used as a foreign key to join to another table.
@PrimaryKeyJoinColumn
- Specifies a primary key column that is used as a foreign key to join to another table.
- It may be used in a OneToOne mapping in which the primary key of the referencing entity is used as a foreign key to the referenced entity.