spring3.1和Hibernate4.2整合,No Session found for current thread
2013-06-20 22:36
330 查看
最近整合spring3.1 + spring mvc + Hibernate4.2时遇到的问题,问题虽然解决了,但是并不明白其中的道理,自己做个备忘。
编写的测试类执行数据库操作,使用sessionFactory.getCurrentSession()开始一直报 No Session found for current thread
无意之中看到你的这篇文章,把下面两句加在测试类上,就运行正常
@Transactional @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
以下这句话可有可无
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
关键是@Transactional这句注解,看来是事务的问题,我不明白的是为什么加上就可以?
难道@ContextConfiguration("classpath:applicationContext.xml")这句话并没有把配置文件该装配的对象装配,通过@Autowired织入的业务对象Service并不是代理对象?
如果有大牛路过,希望留下你的脚印,让我们望着你们的脚步前进哈。
相关文章推荐
- Spring整合hibernate No Session found for current thread
- Spring 3 和 Hibernate4 整合时遇到的 No Session found for current thread !
- spring3 与 Hibernate4集成报错 No Session found for current thread
- 关于在Spring中Hibernate的No Session found for current thread问题
- SpringMVC 整合 hibernate 报错:No Session found for current thread
- Spring-Hibernate - No Session found for current thread
- spring+hibernate整合:报错org.hibernate.HibernateException: No Session found for current thread
- Spring framework3.2整合hibernate4.1报错:No Session found for current thread
- Spring framework3.2整合hibernate4.1报错:No Session found for current thread
- Spring framework3.2整合hibernate4.1报错:No Session found for current thread
- 关于Spring3.2+Hibernate4.1整合问题:No Session found for current thread
- Sping3.1和hibernate4.2集成—— No Session found for current thread
- Hibernate4 与 spring3 集成Hibernate4 No Session found for current thread
- Hibernate4 与 spring3 集成之后 “No Session found for current thread”
- org.hibernate.HibernateException: No Session found for current thread
- Hibernate4 No Session found for current thread原因
- Hibernate4 No Session found for current thread
- Hibernate No Session found for current thread异常分析
- org.hibernate.HibernateException: No Session found for current thread
- Hibernate: No Session found for current thread