【发布时间】:2018-07-09 09:33:06
【问题描述】:
我正在使用带有 springboot 1.5.14 的休眠 5.0.12。
我的实体有这个 id
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "UserID", nullable = true)
public int getUserId() {
return this.userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
在我的数据库中有id = 0 的礼物记录。
如果我读取、编辑和保存这些记录,hibernate 会使用生成的新 ID 复制这些记录。
如何配置休眠以允许id = 0 值?
在 eclispelink 中这个配置是"eclipselink.id-validation" = "NULL"
【问题讨论】: