Could not obtain transaction-synchronized Session for current thread 错误的解决方法!
BsTable bsTable = new BsTable();
// String time = request.getParameter("date");
String time = Constant.getStringDate(0);
Map<String, String> map = new HashMap<String, String>();
map.put("attendanceDate", time);
params.clear();
params.putAll(map);
StringBuilder strSQL = new StringBuilder("SELECT apply_user_name 'name', ");
strSQL.append(" count(CASE WHEN type='1' THEN type END) 'field1', "); //迟到
strSQL.append(" count(CASE WHEN type='3' THEN type END) 'field3', "); //未签到
strSQL.append(" count(CASE WHEN type='4' THEN type END) 'field4', "); //请假
strSQL.append(" count(CASE WHEN type='5' THEN type END) 'field5', "); //外出
strSQL.append(" count(CASE WHEN leave_type='病假' THEN leave_type END) 'field10',"); //病假
strSQL.append(" count(CASE WHEN leave_type='事假' THEN type END) 'field11' "); //事假
strSQL.append(" FROM t_sign_record_late ");
strSQL.append(" WHERE attendance_date=:attendanceDate");
strSQL.append(" GROUP BY apply_user_name ");
List report_list = signRecordReportDao.findBySql(strSQL.toString(), params);
String strSQL_count = "SELECT COUNT(*) FROM (" + strSQL.toString() + ") t";
bsTable.setTotal(signRecordReportDao.countBySql(strSQL_count).longValue());
bsTable.setRows(report_list);
return bsTable;
SpringMVC + Hibernate,使用事务管理 Service 层。但是这段代码放在 controller 里面就会遇到错误!
解决方法就是把数据库的相关操作放在 Service 层,用事务来管理就不会出错了
Could not obtain transaction-synchronized Session for current thread 错误的解决方法!的更多相关文章
- 记一次bug思考过程:HibernateException: Could not obtain transaction-synchronized Session for current thread
场景:把从客户端提交的任务放到线程池执行 异常:HibernateException: Could not obtain transaction-synchronized Session for cu ...
- Hibernate4中使用getCurrentSession报Could not obtain transaction-synchronized Session for current thread
架个spring4+hibernate4的demo,dao层直接注入的sessionFactory,然后用getCurrentSession方法获取session,然后问题来了,直接报错: Could ...
- Could not obtain transaction-synchronized Session for current thread原因及解决方案
在开发中,碰到到了Could not obtain transaction-synchronized Session for current thread异常,因此特意记录下. 一.问 ...
- 关于Hibernate Could not obtain transaction-synchronized Session for current thread
转载自 http://blog.csdn.net/flyjiangs/article/details/51537381 最近几年一直再搞android,最近闲下来了,顺便玩一下web. 整了个最新版本 ...
- 关于Could not obtain transaction-synchronized Session for current thread 这个异常。
Could not obtain transaction-synchronized Session for current thread 这个异常之前非常让我头大.对于网上的各种说法都试了一下反正都不 ...
- org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
spring与hibernate整合报错 org.hibernate.HibernateException: Could not obtain transaction-synchronized Ses ...
- Hibernate Could not obtain transaction-synchronized Session for current thread问题处理
项目通过Hibernate查询时报出如下错误: Hibernate Could not obtain transaction-synchronized Session for current thre ...
- The address where a.out.debug has been loaded is missing以及No symbol "*" in current context原因与解决方法
最近,在debug core的时候,发现p 变量的时候提示“No symbol "*" in current context”,我们的代码使用-g编译的,经查有可能是下列几个原因或 ...
- MYSQL安装时解决要输入current root password的解决方法
在装MYSQL的时候发现要输入current root password不记得以前在电脑里装过(你的系统曾经装过MYSQL在重装就会要求输入原来设定的密码,如果是第一次安装就不会出现),在网上苦苦搜寻 ...
随机推荐
- 爬虫入门之jsonPath PhantomJS与 selenium详解(六)
1 jsonPath数据格式 pip安装: pip install jsonpath 用来解析json格式的字符串,类似于xpath (1) json对象的转换 json.loads() json.d ...
- 关于Visio的vba操作,遍历目录,对所有vsd文件操作,导入excel文件
1.vba遍历要添加引用,runtime 2.不能打开单独的application,因为在获取到shape的picture属性时候,新打开的application不能够获取到.提示自动化错误. 3.定 ...
- 安装PYTHON PIL包
安装pillow而不是PIL pip install pillow 参考: https://github.com/python-pillow/Pillow
- 大小端,"字节序"
2 字节序 2.1 字节 字节(Byte)作为计算机世界的计量单位,和大家手中的人民币多少多少“元”一个意思.反正,到了计算机的世界,说字节就对了,使用人家的基本计量单位,这是入乡随俗. 比如,一个电 ...
- HDU 1205 鸽巢原理
#include <bits/stdc++.h> using namespace std; long long abs_(long long a,long long b) { if(a&g ...
- python nmap模块使用进行主机探测(ICMP)
终于审核通过了......第一次用博客,想记录自己的学习情况,分享知识. 废话不多说,第一篇blog,大牛请轻喷. 资产清点首先需要进行主机探测,将存活主机统计下来再进行进一步的指纹识别及端口探测.若 ...
- POJ 1986 Distance Queries 【输入YY && LCA(Tarjan离线)】
任意门:http://poj.org/problem?id=1986 Distance Queries Time Limit: 2000MS Memory Limit: 30000K Total ...
- Hinge Loss
http://blog.csdn.net/luo123n/article/details/48878759 https://en.wikipedia.org/wiki/Hinge_loss ...
- 【luogu P3378 堆】 模板
题目链接:https://www.luogu.org/problemnew/show/P3378 是堆的模板...我懒,STL da fa is good #include <iostream& ...
- vim_preview_window
*29.2* The preview window When you edit code that contains a function call, you need to use the c ...