In JPA 2.1, section 11.1.44 PrimaryKeyJoinColumn Annotation: "it may be used in a OneToOne mapping in which the primary key of the referencing entity is used as a foreign key [118] to the referenced entity [119]. [118] It is not expected that a database foreign key be defined for the OneToOne mapping, as the OneToOne relationship may be defined as “optional=true”. [119] The derived id mechanisms described in section 2.4.1.1 are now to be preferred over PrimaryKeyJoinColumn for the OneToOne mapping case." Your test case involves an ID annotated with PrimaryKeyJoinColumn. The only mention of such usage is in section 2.4.1.3 Examples of Derived Identities, Example 4, Case (b) footnote: "[15] Note that the use of PrimaryKeyJoinColumn instead of MapsId would result in the same mapping in this example. Use of MapsId is preferred for the mapping of derived identities" However, Example 4, Case (b) has a separate ID property to which the @MapsId (or @PrimaryKeyJoinColumn) would refer, and your test case does not. The example that is more relevant to your test case is Example 4, Case (a) which simply uses a JoinColumn on the ID property itself: {{@Id @OneToOne @JoinColumn(name="FK") Person patient;}} I've confirmed that changing @PrimaryKeyJoinColumn to JoinColumn works as expected. |