[Error]: createQuery is not valid without active transaction
2017-08-28 10:54
429 查看
[Error]: createQuery is not valid without active transaction
1) 在整合Struts2
Spring以及
Hibernate5时,最终出现上述异常,还有一下现象:
利用 hibernate 自动创建表时,log 中出现了执行的 sql 语句而数据库中却没有创建出来。
2) 最终发现是因为 Hibernate 的 核心配置 中添加了如下配置:
<property name="hibernate.current_session_context_class">thread</property>
也就是把
session绑定到 hibernate 线程。然而这时,我们已经把
sessionFatory的创建交给了
Spring所以此时这样绑定是不对的。可以修改为:
<property name="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</property>
3) 最后感谢
yinjian520的博客
相关文章推荐
- 编程异常——如果你报createSQLQuery is not valid without active transaction,...
- createQuery is not valid without active transaction异常
- 使用spring4+springMVC+hibernate5 时报错:createQuery is not valid without active transaction;
- [transaction] org.hibernate.HibernateException: createQuery is not valid without active transaction
- 使用S2SH框架时,出现org.hibernate.HibernateException: createQuery is not valid without active transaction
- createQuery is not valid without active transaction
- 如果你报createSQLQuery is not valid without active transaction,请看这里
- 异常积累(一)createQuery is not valid without active transaction
- org.hibernate.HibernateException: createSQLQuery is not valid without active transaction
- Spring管理Hibernate 报 createQuery is not valid without active transaction 错误
- ssh整合报错org.hibernate.HibernateException: createQuery is not valid without active transaction
- spring整合hibernate的时候报异常org.hibernate.HibernateException: createQuery is not valid without active transaction
- 编程异常——假设你报createSQLQuery is not valid without active transaction,...
- createQuery is not valid without active transaction
- createQuery is not valid without active transaction
- 错误createSQLQuery is not valid without active transaction
- 如果你报createSQLQuery is not valid without active transaction,请看这里
- createSQLQuery is not valid without active transaction的解决办法
- <转>如果你报createSQLQuery is not valid without active transaction,请看这里
- 如果你报createSQLQuery is not valid without active transaction,请看这里