原文:No Hibernate Session bound to thread, and configuration does not allow

今天晚上挺悲催的,遇到了这个问题花费我很长时间,现在总结如下: 到这这种情况的发生有两种情况: ,没有配置事物只要在Spring配置文件中添加如下代码: 然后在DAO程序前面加上 Transactional即可。 ,连接数据的配置是否正确,如果连接字符串不正确的话,就不能够创建SessionFactory,也就无从谈起事务了。 我的问题是第二种,我怎么能想到,我会粗心到数据库连接字符串弄错呢 ...

2012-03-28 22:39 2 21622 推荐指数:

查看详情

HibernateException: No Hibernate Session bound to thread

解决No Hibernate Session bound to thread  背景交代   在使用this.getHibernateTemplate().getSessionFactory().getCurrentSession()方法获取session时报以下异常信息 ...

Thu Feb 04 19:02:00 CST 2016 0 5299
Hibernate中解决No Hibernate Session bound to thread问题

引用:忘了 首先是getCurrentSession()与openSession()的区别: 1、getCurrentSession()与openSession()的区别?   * 采用getCurrentSession()创建的session会绑定到当前线程中,而采用 ...

Tue Mar 14 03:25:00 CST 2017 0 2884
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM