Given the following mapping:
@OneToOne
@MapsId
@PrimaryKeyJoinColumn(name = "id") private User user;
The column name is simply ignored. There are two possible workarounds:
- Remove @MapsId and add optional=false :
@OneToOne(optional = false)
@PrimaryKeyJoinColumn(name = "id")
private User user;
- Use @JoinColumn instead of @PrimaryKeyJoinColumn
@OneToOne
@MapsId
@JoinColumn(name = "id")
But my reading of the JPA spec is that the first example should work. |