org.hibernate.HibernateException: No Hibernate Session bound to thread
来源:互联网 发布:海康威监控无网络视频 编辑:程序博客网 时间:2024/05/18 01:36
项目启动时抛异常:org.hibernate.HibernateException: No Hibernate Session bound to thread,
出现此异常的情况或有多种:DataSource数据源、事务未正常运行、session获取失败。
先说说spring如何对事务和hibernate session进行管理的:
1.getCurrentSession()是必须提交事务的。故使用getSessionFactory().getCurrentSession()时,这个方法一定是要配置声明式事务管理。
2.openSession()恰恰是与以上的方法想法,它不需要提交事务。但是他的资源必须手动关闭。
相对以上两点,解决方法有
1.获得session时使用openSession()。
2.若用到getCurrenctSession(),需在sessionFactory中配置(当然也可以使用注解,在service类加上事务@Transactional)
<prop key="hibernate.current_session_context_class">thread</prop><prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
0 0
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and
- 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
- HibernateException: No Hibernate Session bound to thread
- HibernateException: No Hibernate Session bound to thread
- 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
- 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
- ssh 中报错:org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- 继承类的@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
- No Hibernate Session bound to thread
- ARM中,总线如何连接?
- centos6搭建本地openstack软件源
- [IOS学习笔记]第一课 类与方法
- 如何集成NUI控件实现快速开发 技术解决方案
- C语言控制台窗口图形界面编程(八):鼠标事件
- org.hibernate.HibernateException: No Hibernate Session bound to thread
- 系统分析与设计——领域模型画法
- Introduction to the Analytical Writing Measure
- ASCII Chart
- JavaJDBC的简单写法包括Oracle、MySQL、SqlServer
- 局域网ip查询shell实现(bat格式执行)
- nefu 120——梅森素数
- ARM中,总线如何连接?
- extern C的作用详解