异常记录:Hibernate:a different object with the same identifier value was already.............

完整异常:
Hibernate:a different object with the same identifier value was already associated with the session
异常翻译:
在同一个session不允许出现同一标识符的不同对象
出现原因:
在查询后,创建一个新的对象来保存这个对象,并使用新对象更新数据库原有对象
解决方法:
没必要创建新的对象,只需在查询完的对象进行修改后调用update更新。

猜你喜欢

转载自blog.csdn.net/weixin_40763557/article/details/80926798