Hibernate的一个经典异常(org.hibernate.NonUniqueObjectException)
来源:互联网 发布:mac cad2014破解 编辑:程序博客网 时间:2024/05/21 14:56
异常为:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:
意思是拥有相同的数据库标识符(代表数据库中的同一条记录),但是具有不同的持久化标识符。
解决办法
1 做一个动作将session关闭 调用Session的 close方法 ,Session的缓存被清空,其中的所有持久化对象都变为游离对象,
2 调用Session的evict()方法能够从缓存中删除一个持久化对象,使其变为游离状态,这样也能达到解决同一个
session中关联两个同一个identifer的对象更新的时候产生的冲突
3 使用session.merge()方法保存对象。
要理解一下使用hibernate时对象的三种状态。
看http://blog.csdn.net/hongchangfirst/article/details/8111824
0 0
- Hibernate的一个经典异常(org.hibernate.NonUniqueObjectException)
- Hibernate的一个经典异常(org.hibernate.NonUniqueObjectException)
- org.hibernate.NonUniqueObjectException异常解决方法
- org.hibernate.NonUniqueObjectException异常解决方法
- 异常org.hibernate.NonUniqueObjectException及其解决
- org.hibernate.NonUniqueObjectException异常解决方法(1)
- org.hibernate.NonUniqueObjectException异常解决方法(2)
- hibernate异常NonUniqueObjectException的处理
- org.hibernate.NonUniqueObjectException
- org.hibernate.NonUniqueObjectException
- org.hibernate.NonUniqueObjectException
- org.hibernate.NonUniqueObjectException学习
- org.hibernate.NonUniqueObjectException 问题
- org.hibernate.NonUniqueObjectException
- org.hibernate.NonUniqueObjectException解决方法
- org.hibernate.NonUniqueObjectException
- org.hibernate.NonUniqueObjectException
- org.hibernate.NonUniqueObjectException
- React Native开发之快速入门React
- 使用GB28181从海康NVR设备上获取实时视频
- cmd语法集锦
- 数据仓库建模小工具
- 关于代码编辑器IDEA突然不能编辑文件的原因
- Hibernate的一个经典异常(org.hibernate.NonUniqueObjectException)
- kolla的一点心得
- 下载HTTP文件
- 掌握java多线程进阶
- PixyMon for win10的安装
- Alluxio安装(以HDFS作为底层文件系统)
- backbonejs上传文件
- get请求
- LINUX运动级别