zoukankan      html  css  js  c++  java
  • 注意资源利用 不然导致资源消耗会很严重

    for(Shop s:list) {
                System.out.println(s.getName());
                String sql="select shopId,sum(ele_bank+ele_card+water_card+water_bank+coal_card+coal_bank) as zonghe ,sum(sale_bank+sale_card) as  sale,sum(cigarette_card+cigarette_bank)  as bacco, sum(yidong_card+yidong_bank+dianxin_card+dianxin_bank)  as recharge from hs_shop_items  where  record_time like '%2013-12-12%' and shopId="+s.getId();
                Session officeSession=officeSessionFactory.openSession();
                officeSession.beginTransaction();
                SQLQuery queryOffice=officeSession.createSQLQuery(sql);
                List<ShopTransDTO>  r=queryOffice.addEntity(ShopTransDTO.class).list();
                res.add(r.get(0));
            }
    

      

    如上图中的

    Session officeSession=officeSessionFactory.openSession();
    officeSession.beginTransaction();
    

      

    这个部分放在循环中是错误的

    应该这么写:

    Session officeSession=officeSessionFactory.openSession();
    officeSession.beginTransaction();
    for(Shop s:list) {
                System.out.println(s.getName());
                String sql="select shopId,sum(ele_bank+ele_card+water_card+water_bank+coal_card+coal_bank) as zonghe ,sum(sale_bank+sale_card) as  sale,sum(cigarette_card+cigarette_bank)  as bacco, sum(yidong_card+yidong_bank+dianxin_card+dianxin_bank)  as recharge from hs_shop_items  where  record_time like '%2013-12-12%' and shopId="+s.getId();
                SQLQuery queryOffice=officeSession.createSQLQuery(sql);
                List<ShopTransDTO>  r=queryOffice.addEntity(ShopTransDTO.class).list();
                res.add(r.get(0));
    }
    

      

  • 相关阅读:
    第3章 敏捷项目管理概述
    第2章 传统与敏捷方法论
    第1章 敏捷思维—“互联网+”知识工作者必备的DNA
    敏捷项目管理架构(APMF)
    敏捷宣言和准则
    研发工程师如何转型项目经理
    软件门外汉的入门进阶
    [摘录]第五部分 经验谈(2)
    [摘录]第五部分 经验谈(1)
    [摘录]第四部分 教训篇(2)
  • 原文地址:https://www.cnblogs.com/toSeeMyDream/p/5537195.html
Copyright © 2011-2022 走看看