A different object with the same identifier value was already associated with the session的解决办法

批量保存实体方法报错是因为要保存的实体表内主键自增

需要在实体@Id注解下添加@GeneratedValue(strategy=GenerationType.IDENTITY)注解即可

学习时的痛苦是暂时的 未学到的痛苦是终生的
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/juanxincai/p/13071202.html