How To Use @MapsId For Sharing Identifier In @OneToOne Relationships
Description: Instead of regular unidirectional/bidirectional @OneToOne better rely on an unidirectional @OneToOne and @MapsId. This application is a proof of concept.
Key points:
- use
@MapsIdon child side - use
@JoinColumnto customize the name of the primary key column - mainly, for
@OneToOneassociations,@MapsIdwill share the primary key with the parent table (idproperty acts as both primary key and foreign key)
Note:
@MapsIdcan be used for@ManyToOneas well

