个人随笔
目录
Batch update returned unexpected row count from update [0]; actual row count
2020-08-22 15:08:47

Hibernate保存数据报错

  1. Batch update returned unexpected row count from update [0]; actual row count

原因是我用的保存方法是

  1. this.getSession().saveOrUpdate(obj);

然后我的model的id又是自己指定的

  1. @Id
  2. @GeneratedValue(generator = "customId")
  3. @GenericGenerator(name = "customId", strategy = "assigned")
  4. public String getId() {
  5. return id;
  6. }

所以就报这个错误了,其实只需要把id改为自动生成模式

  1. @Id
  2. @GenericGenerator(name="systemUUID",strategy="uuid")
  3. @GeneratedValue(generator="systemUUID")
  4. public String getId() {
  5. return id;
  6. }

或者把保存的方法不要用保存或者更新,直接用保存

  1. this.getSession().save(obj);

都可以解决的。

 4638

啊!这个可能是世界上最丑的留言输入框功能~


当然,也是最丑的留言列表

有疑问发邮件到 : suibibk@qq.com 侵权立删
Copyright : 个人随笔   备案号 : 粤ICP备18099399号-2