SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
来源:互联网 发布:w7每次开机网络感叹号 编辑:程序博客网 时间:2024/05/17 22:29
来自 http://blog.csdn.net/caiwenfeng_for_23/article/details/45242545
查了一下相关资料,整理如下:
原因:Hibernate4 No Session found for current thread原因
解决方法:
1. 在spring 配置文件中加入
程序代码
<tx:annotation-driven transaction-manager="transactionManager"/>
并且在处理业务逻辑的类上采用注解
程序代码
@Service
public class CustomerServiceImpl implements CustomerService {
@Transactional
public void saveCustomer(Customer customer) {
customerDaoImpl.saveCustomer(customer);
}
...
}
另外在 hibernate 的配置文件中,也可以增加这样的配置来避免这个错误:
程序代码
<property name="current_session_context_class">thread</property>
0 0
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- Hibernate4中使用getCurrentSession报Could not obtain transaction-synchronized Session for current thread
- Hibernate4中使用getCurrentSession报Could not obtain transaction-synchronized Session for current thread
- 报错 Could not obtain transaction-synchronized Session for current thread
- spring整合hibernate报错:Could not obtain transaction-synchronized Session for current thread
- Hibernate报错:Could not obtain transaction-synchronized Session for current thread
- spring4+hibernate4+junit整合问题 Could not obtain transaction-synchronized Session for current thread的问题
- springmvc+spring4+hibernate4整合Could not obtain transaction-synchronized Session for current thread
- Hibernate4 提示Could not obtain transaction-synchronized Session for current thread
- 【Hibernate】Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- PADS 如何显示铺铜边框 删除死铜 删除铺铜
- kruskal——宿命的PSS
- SQLServer异常捕获
- 关于一些原理概念问题
- XHTML 相对路径与绝对路径
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- PHP 性能追踪及分析工具 xhprof 的安装与使用
- 实习生报告:MVC+asp.net 前端开发与后台同步的问题
- 改变tabbar的selectedindex
- 快速排序及实现(python)
- Java:WeakReference 弱引用
- 在IDEA中实战Git
- numpy学习笔记
- 如何快速转载CSDN中的博客