码迷,mamicode.com
首页 > 编程语言 > 详细

Hibernate 与Spring整合出现 hibernate.HibernateException: createCriteria is not valid without active transaction

时间:2015-09-10 10:51:35      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

当 Hibernate 和 Spring 整合时,在 Spring 中指定的 Hibernate.cfg.xml 文件内容中要注释掉以下内容:

<!-- Enable Hibernate‘s automatic session context management -->
<!-- <property name="current_session_context_class">thread</property> -->
这样,才能将 Hibernate 的 session 交给 Spring 来管理,而 Spring 才能使用切面方法,对 DAO 中的方法进行管理。

在配置文件中注释掉<property name="current_session_context_class">thread</property>后解决

Hibernate 与Spring整合出现 hibernate.HibernateException: createCriteria is not valid without active transaction

标签:

原文地址:http://www.cnblogs.com/FJH1994/p/4796824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!