明哲哈哈哈
2017-10-20 07:31SpringContextUtil.getBean获取的类,没有hibernate的session
背景
一个任务, 需要开启多个线程,同时跑,
我开启的线程中, 用SpringContextUtil.getBean("")获取了一个service类,
这个service中, 有许多的service和dao 用来处理任务
在这个处理方法中, Transaction trans = this.creditchanneldao.getCSession().getTransaction();
通过提取出事务控制,来进行每个线程的独立事务控制
但是,抛异常
No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- SpringContextUtil.getBean获取的类,没有hibernate的session
- spring
- hibernate
- session
- 线程
- 事务
- 2个回答