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在重装就会要求输入原来设定的密码,如果是第一次安装就不会出现),在网上苦苦搜寻 ...
随机推荐
- App更新(Android)
App更新(Android) 前言:现在一般的Android软件都是需要不断更新的,当你打开某个app的时候,如果有新的版本,它会提示你有新版本需要更新.该项目实现的就是这个功能.并且有强制更新和更 ...
- 任务二:零基础HTML及CSS编码练习
任务目的 针对设计稿样式进行合理的HTML架构,包括以下但不限于: 掌握常用HTML标签的含义.用法 能够基于设计稿来合理规划HTML文档结构 理解语义化,合理地使用HTML标签来构建页面 掌握基本的 ...
- linux c 监控目录
static void* thread_monitor(void* args) { pthread_detach(pthread_self()); int fd; int wd; int len; i ...
- win7+jdk1.6+solr4.7.2在内嵌jetty servelt或外置tocmat服务器的solr服务使用
solr安装,目前初步接触solr,了解两种启动方式.一种是自带的jetty,另一种是基于tomcat.由于超过4.7.2版本的solr需要java1.7及以上版本的支持,所以我们选择solr ...
- 面试题之-------使用TCP/UDP协议的常见协议及端口号
使用TCP协议的常见端口主要有以下几种: (1) FTP:定义了文件传输协议,使用21端口.常说某某计算机开了FTP服务便是启动了文件传输服务.下载文件,上传主页,都要用到FTP服务. (2) Tel ...
- spring对数据库的操作、spring中事务管理的介绍与操作
jdbcTemplate的入门 创建maven工程 此处省略 导入依赖 <!-- https://mvnrepository.com/artifact/org.springframework/s ...
- 学习笔记-java 多线程
背景说明: 多线程并发与管理,是java基础知识里的重点,本文根据<java核心技术第八版>中的多线程技术的学习,对知识点进行整理:这里只对基础知识点进行简单罗列,以达到对知识点有网状关联 ...
- vue v-on 带参事件
1.js代码 var list=[ //定义一个数组 {title:} ] var box=new Vue({ el:'.box', data:{ list:list }, methods:{ //d ...
- matlab中换行
若在命令窗口中,如果一条语句已经写完,需要换行,可以用"Shift+Enter", 如果一条语句没写完就想换行,可以使用"...+Enter".
- 关于bootstrap-table服务端分页问题
昨天项目中涉及到了前端表格分页问题.数据一共有1万多条,所以选择了后端分页. 之前用的都是前端分页,第一次使用后端分页.网上也找到了一些例子,最后做出来了. 这里用的是bootstrap-table插 ...