HibernateException: No Hibernate Session bound to thread
来源:互联网 发布:android 视频通话 源码 编辑:程序博客网 时间:2024/05/16 19:33
异常栈:
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
- at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
- at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:622)
- at org.springside.modules.orm.hibernate.SimpleHibernateDao.getSession(SimpleHibernateDao.java:90)
- at org.springside.modules.orm.hibernate.SimpleHibernateDao.createCriteria(SimpleHibernateDao.java:284)
- at org.springside.modules.orm.hibernate.SimpleHibernateDao.findUniqueBy(SimpleHibernateDao.java:165)
使用SessionFactory.getCurrentSession执行hibernate操作时,hibernate的操作默认必须包含在一个transaction中,也就是开始要用session.begionTransaction得到一个transaction 实例(譬如tx), 操作结束时在这个实例上进行事务的提交tx.commit或回滚tx.rollback. 如果这些CRUD操作不被包括在一个具体的transaction中,hibernate就会抛出上述异常。
在实际的SSH web应用开发中,我们通常用spring来进行事务的管理。我们一般不会在dao层使用transaction,事务被配置在service层上更为合理,因为业务层方法表示逻辑上的一个原子操作。在这种环境下,如果你遇到上述异常,请考虑一下service层上没有配置transaction,transaction有没有打开!
0 0
- HibernateException: No Hibernate Session bound to thread
- HibernateException: No Hibernate Session bound to thread
- 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
- 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
- HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation
- No Hibernate Session bound to thread
- No Hibernate Session bound to thread
- springmvc No Hibernate Session bound to thread
- CRT堆
- 第十五周项目3: 两数和与差(用参数带回结果)
- Javase基础学习笔记之集合(4)
- 逻辑思维笔试题3
- ToString
- HibernateException: No Hibernate Session bound to thread
- Android的Listview详解1(ArrayAdapter方式)
- 第十六周 项目五:编程处理C++源代码(5.2:使花括号独占一行)
- MySQL系列:innodb源码分析之表空间管理
- Iphone
- 怎么用QQ查看对方IP
- StringUtils
- 逻辑思维笔试题4
- 读书笔记--《大教堂与集市》