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在重装就会要求输入原来设定的密码,如果是第一次安装就不会出现),在网上苦苦搜寻 ...
随机推荐
- 跨平台移动开发_PhoneGap 警告,通知,鸣叫,振动4 种通知类型
创建鸣叫 使用 confirmation.beep 创建鸣叫 function playBeep() { navigator.notification.beep(1); } 创建振动 使用 ...
- hibernate基础配置
数据库表名和类名 一致 注解:可写可不写: XML:可写可不写: <class name="Student"> 不一致 注解: public class Teache ...
- Cloud Foundry和微服务Meetup重磅来袭
CF 同学们: Cloud Foundry 2016 上海 Meetup 将在10月22日在上海港汇广场进行! 想要参会的小伙伴,请直戳 ~ 在过去的一年,CF 的技术有很多进展,微服务也是2016 ...
- Hadoop ->> MapReduce编程模型
对于MapReduce模型的实现,有Java等一些语言实现了接口,或者用像Hive/Pig这样的平台来操作.MapReduce由Map函数.Reduce函数和Main函数实现.第一步,源数据文件按默认 ...
- Anaconda中spyder 安装tensorflow
关于Anaconda的安装就不介绍了,本文主要介绍spyder中安装 tensorflow.废话少说 直接重点: 1.安装好Anaconda之后,找到spyder图标 点击install,等待安装完成 ...
- .NET部分知识点整理
.Net学习 Visual Studio2018 企业版:NJVYC-BMHX2-G77MM-4XJMR-6Q8QF 专业版:KBJFW-NXHK6-W4WJM-CRMQB-G3CDH 开发工具常用V ...
- 实现两个N×N矩阵的乘法,矩阵由一维数组表示
此题的关键在于找到矩阵乘法的不变式! 例如: 矩阵a × 矩阵b = 矩阵ab 1 2 5 6 × 3 4 7 8 显然 ab[0] = a[0] * b[0] + a[1] * b[2] ab[1] ...
- netstat 和 lsof 查看网络状态
netstat和lsof都是linux下的工具,可以用于查看系统的网络状态. netstat netstat可以打印 网络连接,路由表,接口统计数据,还有多播和masquerade连接相关的东西(不熟 ...
- 解决SQLite打开已有路径下的db问题
最近遇到的需要加载已有路径下(sd card下)db的问题,找了一下资料,以下是解决的方法,仅供参考(转载自eoe): SQLiteOpenHelper 是Android框架为我们提供的一个非常好的数 ...
- POJ-3273 Monthly Expense---最小化最大值
题目链接: https://cn.vjudge.net/problem/POJ-3273 题目大意: 给N个数,划分为M个块(不得打乱数顺序).找到一个最好的划分方式,使得块的和的最大值 最小 解题思 ...