org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
来源:互联网 发布:淘宝上质量好的女装店 编辑:程序博客网 时间:2024/05/21 13:22
在用Spring于Hibernate整合的时,在没有配置Spring的事物管理时。使用Hibernate进行事物进行管理时可能会出现此异常
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
原因是你没有配置Spring的事物管理,或者因为hibernate.current_session_context_class的默认值是JTA所以你无法从当前线程中获得一个Session。
解决方法有三种:
1.在Spring中配置Spring的事物管理,我们一般都会使用此种方法。
2.如果你暂时还不想配置Spring的事物管理,此时可以用SessionFactory的OpenSession()方法获得一个新的Session,而不是用getCurrentSession()方法。
3.也可以在配置文件中将hibernate.current_session_context_class的值改为Thread,此时便可以用getCurrentSession()方法从当前线程中获取Session。
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
- 继承类的@Transactional:org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow crea
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transac
- HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and
- ssh 中报错:org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration
- No Hibernate Session boundNo Hibernate Session bound to thread, and configuration does not allow cr
- Spring+Hibernate 异常No Hibernate Session bound to thread, and configuration does not allow creation
- org.hibernate.HibernateException: No Hibernate Session bound to thread
- org.hibernate.HibernateException: No Hibernate Session bound to thread
- org.hibernate.HibernateException: No Hibernate Session bound to thread
- No Hibernate Session bound to thread, and configuration does not allow creation of non-transactiona
- No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional
- css 超级连接的四种状态
- error LNK2023: bad DLL or entry point 'msobj80.dll' 解决方法
- ADT的安装和配置
- JSON数据格式必知
- GPON Type B保护
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- 【easyUI】<div class="demo-info">
- android-如何获得当前正在运行的activity的相关信息
- 软件开发细节总结
- VC 注册表读写
- 再次写给我们这些浮躁的程序员
- css学习之选择器
- 通过MySQL提供的C API访问MySQL数据库
- java线程基础