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。
网友评论