工作札记--“ids for this class must be manually assigned before calling save”解决办法

来源:互联网 发布:免费抽奖软件 编辑:程序博客网 时间:2024/05/22 10:22

一般是没没有在XXX.java中对主键设置自增长造成的。

加入以下代码即可:

@GeneratedValue(strategy=GenerationType.AUTO)


如:

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}

原创粉丝点击