A one-to-one relationship associates each entity instance with at most one instance of another entity type. In persistence models, choose it when the database and domain require that cardinality, rather than introducing a collection unnecessarily. section 9.1 section 9.5
Select the mapping strategy according to ownership, identity, and optionality:
- Use an embeddable component when the related value has a dependent lifecycle, as with a user's billing, home, or shipping address. section 9.1
- Use a dedicated entity when references can be shared, requiring the related object to have its own identity. section 9.1
- Choose a shared primary key when one entity is always stored before the other and can supply the primary key. section 9.1.4
- Choose a foreign-key association in other cases, or use a join table when the relationship is represented through an intermediate link. section 9.1.4
Optional shipment-to-item association
An escrow application can model a Shipment with an optional one-to-one Item association. The ITEM_SHIPMENT table uses SHIPMENT_ID as its primary key and makes ITEM_ID unique, preventing either shipment or item from participating in more than one link. A JPA mapping uses @OneToOne and @JoinTable; lazy loading still checks the join table when loading Shipment. section 9.1.4
Spring Data JDBC user and address
Spring Data JDBC models one Address inside User with @MappedCollection(idColumn = "USER_ID"). The USERS table's ID becomes the foreign key in ADDRESSES, while separate CrudRepository interfaces persist and test both entities. section 15.3.1
Use the entity diagram to distinguish an Address entity with its own identity from a component-valued address. section 9.1


