spring data jpa 2.3.0.M2 新增问题
Hibernate: select next_val as id_val from hibernate_sequence for update
Hibernate: update hibernate_sequence set next_val= ? where next_val=?
Hibernate: insert into tmenu (ICONCLS, TEXT, PID, URL, id) values (?, ?, ?, ?, ?)
2020-02-18 15:38:45.135 WARN 75736 --- [o-12020-exec-97] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1062, SQLState: 23000
2020-02-18 15:38:45.135 ERROR 75736 --- [o-12020-exec-97] o.h.engine.jdbc.spi.SqlExceptionHelper : Duplicate entry '2' for key 'tmenu.PRIMARY'
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [tmenu.PRIMARY]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:298)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255)
谁遇到过这样的问题
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是主键重复啊。
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer getId() {
return this.id;
}
问题出在这 我之前没有写 (strategy = GenerationType.IDENTITY) 只写了@GeneratedValue