org.hibernate.TransientObjectException: The instance was not associated with this session解决方法
来源:互联网 发布:nginx日志分析工具 编辑:程序博客网 时间:2024/06/05 16:50
出现这个异常的原因就是把一个瞬态对象当做持久化对象来操作了。解决的办法当然就是把对象持久化了,可以调用session的save() 或者saveOrUpdate()方法
下面来科普一下hibernate在对象中的三种状态:
简单的说一下就是这样子,
1、当一个对象被new了以后此对象处于瞬时态(Transient);
2、然后对此对象执行session的save() 或者saveOrUpdate()方法后,此对象被放入session的一级缓存进入持久态.
2、当再对此对象执行evict()/close()/clear()的操作后此对象进入游离态(Detached)
4、游离态(Detached)和瞬时态(Transient)的对象由于没有被session管理会在适当的时机被java的垃圾回收站(garbage)回收.
5、执行session的get()/load()/find()/iternte()等方法从数据库里查询的到的对象,处于持久态(Persistent).
6、当对数据库中的纪录进行update()/saveOrUpdate()/lock()操作后游离态的对象就过渡到持久态
7、处于持久态(Persistent)与游离态(Detached)的对象在数据库中都有对应的记录.
8、瞬时态(Transient)与游离态(Detached)的对象都可以被回收可是瞬时态的对象在数据库中没有对应的纪录,而游离态的对象在数据库中有对用的纪录。
15 0
- org.hibernate.TransientObjectException: The instance was not associated with this session解决方法
- hibernate.cache.auto_evict_collection_cache 报错:The instance was not associated with this session/org
- A different object with the same identifier value was already associated with the session错误解决方法
- Hibernate Exception: a different object with the same identifier value was already associated with the session
- Hibernate更新a different object with the same identifier value was already associated with the session
- [Hibernate]a different object with the same identifier value was already associated with the session
- Hibernate:a different object with the same identifier value was already associated with the session
- hibernate a different object with the same identifier value was already associated with the session
- Hibernate :A different object with the same identifier value was already associated with the session
- hibernate:a different object with the same identifier value was already associated with the session
- org.hibernate.NonUniqueObjectException:a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- a different object with the same identifier value was already associated with the session 一个经典的hibernate错误
- hibernate 中错误a different object with the same identifier value was already associated with the session
- 摇骰子(娱乐)
- 兼容多浏览器的本地存储
- Nginx安装配置以及配置文件详细说明
- Android内核驱动开发中的Kconfig文件结构分析(图文)
- Duplicate Elimination in Scrapy(转)
- org.hibernate.TransientObjectException: The instance was not associated with this session解决方法
- C++delete和delete[]区别
- 骰子
- 1/3-3/5+5/7-7/9…+19/21求和
- JFreeChart的使用
- 关于input单选与复选是否选中值问题
- 黑马程序员 C#学习笔记⑤ 省市县三级联动查询
- 利用 ant 脚本修改项目包名
- 随机数摇骰子