Spring 整合 hibernate 时,抛异常: createQuery is not valid without active transaction

来源:互联网 发布:维尔迪数据 编辑:程序博客网 时间:2024/05/19 13:18

在ssh4中的sessionFactory配置文件中应将hibernate.current_session_context_class设为org.springframework.orm.hibernate3.SpringSessionContext(默认为此值),并应用spring管理事务。

如果为<prop key="hibernate.current_session_context_class">thread</prop> 则会报该异常。


解决方案:

将 <prop key="hibernate.current_session_context_class">thread</prop> 删除,

或者改为默认值:org.springframework.orm.hibernate3.SpringSessionContext


0 0
原创粉丝点击