如何声明主键是一对一的字段?

时间:2017-03-29 10:02:22

标签: java jpa spring-data-jpa

如果我这样写

<html amp>

它说

@Id
@OneToOne
@JoinColumn(name="Id")
private Region region;

我不希望它是复合键,我只想将Composite-id class must implement Serializable: ....InPopulation 替换为适当ID的id

1 个答案:

答案 0 :(得分:1)

你使用MapsId注释(我假设如何声明@Id):

@Id
private Long id;

@JoinColumn(name = "Id")
@OneToOne
@MapsId
private Region region;