码迷,mamicode.com
首页 > 其他好文 > 详细

按照group by分组,显示每个人员的分数累计值

时间:2015-01-12 14:39:32      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

 public List<JfAuction> getListScoreByJfEventId(Integer jfEventId){
        List<JfAuction> jfAuctionList=null;
        String hql ="select j.id,j.user,j.jfEvent,sum(j.score),j.status,j.createTime from JfAuction j where 1=1 ";
        hql+=" and j.jfEvent.id =";
        hql+=jfEventId;
        hql+="  group by j.user.id";
        Query query = jfAuctionDao.getSession().createQuery(hql);
        List list=query.list();
        if(list!=null && list.size()>0){
            jfAuctionList=new ArrayList<JfAuction>();
            for(int i=0;i<list.size();i++){
                JfAuction jfAuction=new JfAuction();
                Object[] obj=(Object[])list.get(i);
                System.out.println(obj[0]);
                System.out.println(obj[1]);
                System.out.println(obj[2]);
                System.out.println(obj[3]);
                System.out.println(obj[4]);
                System.out.println(obj[5]);
                jfAuction.setId((Integer)obj[0]);
                jfAuction.setUser((User)obj[1]);
                jfAuction.setJfEvent((JfEvent)obj[2]);
                jfAuction.setScore( Integer.parseInt(obj[3].toString()));
                jfAuction.setStatus((Integer)obj[4]);
                jfAuction.setCreateTime((Timestamp) obj[5]);
                jfAuctionList.add(jfAuction);
            }
        }
        return jfAuctionList;
    }

按照group by分组,显示每个人员的分数累计值

标签:

原文地址:http://www.cnblogs.com/zifashaonian10000/p/4218261.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!