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 错误的解决方法!的更多相关文章

  1. 记一次bug思考过程:HibernateException: Could not obtain transaction-synchronized Session for current thread

    场景:把从客户端提交的任务放到线程池执行 异常:HibernateException: Could not obtain transaction-synchronized Session for cu ...

  2. Hibernate4中使用getCurrentSession报Could not obtain transaction-synchronized Session for current thread

    架个spring4+hibernate4的demo,dao层直接注入的sessionFactory,然后用getCurrentSession方法获取session,然后问题来了,直接报错: Could ...

  3. Could not obtain transaction-synchronized Session for current thread原因及解决方案

            在开发中,碰到到了Could not obtain transaction-synchronized Session for current thread异常,因此特意记录下. 一.问 ...

  4. 关于Hibernate Could not obtain transaction-synchronized Session for current thread

    转载自 http://blog.csdn.net/flyjiangs/article/details/51537381 最近几年一直再搞android,最近闲下来了,顺便玩一下web. 整了个最新版本 ...

  5. 关于Could not obtain transaction-synchronized Session for current thread 这个异常。

    Could not obtain transaction-synchronized Session for current thread 这个异常之前非常让我头大.对于网上的各种说法都试了一下反正都不 ...

  6. org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread

    spring与hibernate整合报错 org.hibernate.HibernateException: Could not obtain transaction-synchronized Ses ...

  7. Hibernate Could not obtain transaction-synchronized Session for current thread问题处理

    项目通过Hibernate查询时报出如下错误: Hibernate Could not obtain transaction-synchronized Session for current thre ...

  8. 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编译的,经查有可能是下列几个原因或 ...

  9. MYSQL安装时解决要输入current root password的解决方法

    在装MYSQL的时候发现要输入current root password不记得以前在电脑里装过(你的系统曾经装过MYSQL在重装就会要求输入原来设定的密码,如果是第一次安装就不会出现),在网上苦苦搜寻 ...

随机推荐

  1. android学习之VelocityTracker

    今天大概的学习了一下 VelocityTracker ,用来监控手势速度的,在View移动过程中,可以有个缓冲的移动.  我觉得初步的使用起来是很简单的. 首先移动依靠的是Scroller类,Scro ...

  2. 3.GlusterFS 企业分布式存储的搭建

    3.1 硬件要求 一般选择 2U 机型,磁盘 SATA 盘 4TB,如果 IO 要求比较高,可以采购 SSD 固态硬盘.为了充分保证系统的稳定性和性能,要求所有 glusterfs 服务器硬件配置尽量 ...

  3. scrum3

    首先我一直做的是框架的设计,但不同的是这次我们整合完善了这个软件目前的所有需求也定义好了它的大题框架,总的来说设计部分已经结束,现在也就是本次冲刺,我们将重点进行整个软件的数据库编程环节,也就是用SQ ...

  4. 使用Cloud application Studio在C4C UI里创建下拉列表(dropdown list)

    在Cloud Application Studio里新建一个Code List Data Type: 维护Value和描述信息,以及在ABSL里使用的constant值. 保存之后,上述维护的信息会存 ...

  5. python 用cookie模拟登陆网站

    import re import requests def get_info(url): headers = { "Cookie" :"***************** ...

  6. POJ 1984 Navigation Nightmare 【经典带权并查集】

    任意门:http://poj.org/problem?id=1984 Navigation Nightmare Time Limit: 2000MS   Memory Limit: 30000K To ...

  7. 腾讯2016校招编程题【PHP实现】

    2016腾讯春招的编程题 话不多说,直接上题!!! 给定一个字符串s,你可以从中删除一些字符,使得剩下的串是一个回文串.如何删除才能使得回文串最长呢?输出需要删除的字符个数 . 这道题是以回文为载体, ...

  8. apache 配置跨域访问

    在httpd.conf找到  去掉# LoadModule headers_module modules/mod_headers.so 然后在 独立域名配置 加入 Header set Access- ...

  9. 逻辑回归(分类问题)(Logistic Regression、罗杰斯特回归)

    逻辑回归:问题只有两项,即{0, 1}.一般而言,回归问题是连续模型,不用在分类问题上,且噪声较大,但如果非要引入,那么采用逻辑回归模型. 对于一般训练集: 参数系统为: 逻辑回归模型为:      ...

  10. springmvc时间(date)无法转入后台(@DateTimeFormat+@JsonFormat(GMT+8))

    spring时间(date)无法转入后台 Type Status Report Description The server cannot or will not process the reques ...