美文网首页我爱编程
Spring+Hibernate事务管理异常一览表

Spring+Hibernate事务管理异常一览表

作者: 游牧族人 | 来源:发表于2018-05-27 10:24 被阅读28次

1、org.hibernate.HibernateException: createQuery is not valid without active transaction
异常信息:执行操作没有在一个事务中进行。
解决:
先看自己的transactionManager有没有配置好。
配置好transactionManager后查看hibernate是否有hibernate.current_session_context_class属性
有hibernate.current_session_context_class属性后查看他的值是否为org.springframework.orm.hibernate5.SpringSessionContext。
spring在于hibernate整合进行事务管理的时候,不能使用hibernate自己的thread session,所以hibernate的hibernate.current_session_context_class属性必须是org.springframework.orm.hibernate5.SpringSessionContext。

相关文章

网友评论

    本文标题:Spring+Hibernate事务管理异常一览表

    本文链接:https://www.haomeiwen.com/subject/nzcbjftx.html