diff --git a/documentation/src/main/asciidoc/introduction/Mapping.adoc b/documentation/src/main/asciidoc/introduction/Mapping.adoc index e5ea4e1754..cc2fbe0f07 100644 --- a/documentation/src/main/asciidoc/introduction/Mapping.adoc +++ b/documentation/src/main/asciidoc/introduction/Mapping.adoc @@ -517,6 +517,27 @@ class Book { Again, the `foreignKey` member is optional. +[TIP] +==== +For mapping a `@OneToOne` association <> with `@MapsId`, Hibernate lets us use either `@JoinColumn` or `@PrimaryKeyJoinColumn`. +[source,java] +---- +@Entity +class Author { + @Id + Long id; + + @OneToOne(optional=false, fetch=LAZY) + @MapsId + @PrimaryKeyJoinColumn(name="personId") + Person author; + + ... +} +---- +Arguably, the use of `@PrimaryKeyJoinColumn` is clearer. +==== + [[primary-key-column-mappings]] === Mapping primary key joins between tables