读书人

Hibernate错误: is not valid withou

发布时间: 2012-11-20 09:55:44 作者: rapoo

Hibernate异常:***** is not valid without active transaction

导致整个异常的原因可能是,当 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 中的方法进行管理。

读书人网 >软件架构设计

热点推荐