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. IP:192.168.21.173 子网掩码:255.255.255.0 网关:192.168.21.2 DNS:8.8.8.8 8.8.4.4 1、设置IP地址、网关 ee /etc/rc.conf #编辑 ifconfig_em0="inet 192.168.21.173 netmask 255

    IP:192.168.21.173子网掩码:255.255.255.0网关:192.168.21.2DNS:8.8.8.88.8.4.41.设置IP地址.网关ee /etc/rc.conf #编辑if ...

  2. Azure 12 月新公布

    Azure 12 月新发布:人脸识别 API 推出更新,媒体服务当前几种计量方式的调整,Azure Media Redactor 提供预览, Azure 密钥保管库开始计费, 和 Azure 支付方式 ...

  3. SpringBoot热部署插件

    1.配置在 maven工程中的pom.xml文件中 2.SpringBoot框架中提供的一个热部署插件,利用该热部署插件,我们可以在修改代码后不用重启应用,大大提高开发效率:

  4. Appium的DesiredCapabilities参数设置

    Appium的DesiredCapabilities参数设置 DesiredCapabilities 负责启动服务端时的参数设置.实际使用时根据自己的需要,可自行修改一些参数. 比如,应用程序在查找某 ...

  5. [EffectiveC++]item31:将文件间的编译依存关系降至最低

    P143:“声明的依赖性"替换“定义的依存性”

  6. BZOJ3874:[AHOI2014&JSOI2014]宅男计划(爬山法)

    Description  [故事背景] 自从迷上了拼图,JYY就变成了个彻底的宅男.为了解决温饱问题,JYY 不得不依靠叫外卖来维持生计. [问题描述] 外卖店一共有N种食物,分别有1到N编号.第i种 ...

  7. Android——Intent,Bundle

    Intent——切换activity intent.setClass(first.this,second.class); startActivity(intent); Bundle——切换时数据传递 ...

  8. linux系统命令与常识

    之前短期学过linux,用到时才发现已经忘得一干二净了. 现在对学过的和了解到的做一个总结: 先明确一些使用工具: winscp : WinSCP是一个Windows环境下使用SSH的开源图形化SFT ...

  9. vue2 自定义全局组件(Loading加载效果)

    vue2 自定义全局组件(Loading加载效果) github地址: https://github.com/ccyinghua/custom-global-component 一.构建项目 vue ...

  10. SpringBoot非官方教程 | 第二十四篇: springboot整合docker

    转载请标明出处: 原文首发于:https://www.fangzhipeng.com/springboot/2017/07/11/springboot24-docker/ 本文出自方志朋的博客 这篇文 ...