hibernate 保存出错:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.scyd.entity.ProviderProduct#6]
解决方法:在DAO层保存数据时使用merge方法替换save方法
本文介绍了在处理Hibernate数据持久化时遇到的NonUniqueObjectException异常,通过将数据保存方法从save更改为merge,成功解决了问题。详细解释了两种方法的区别及适用场景。
hibernate 保存出错:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.scyd.entity.ProviderProduct#6]
解决方法:在DAO层保存数据时使用merge方法替换save方法
349
4150
988
253

被折叠的 条评论
为什么被折叠?