注意资源利用 不然导致资源消耗会很严重
Posted Fight With Me!!!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了注意资源利用 不然导致资源消耗会很严重相关的知识,希望对你有一定的参考价值。
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)); }
以上是关于注意资源利用 不然导致资源消耗会很严重的主要内容,如果未能解决你的问题,请参考以下文章