hibernate的求和怎么写?
hibernate的求和怎么写?
hibernate的求和怎么写?

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【wer719】截止到2008-07-28 15:12:09的历史汇总数据(不包括此帖):
    发帖的总数量:3                        发帖的总分数:0                        每贴平均分数:0                        
    回帖的总数量:2                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:3                        结贴的总分数:0                        
    无满意结贴数:3                        无满意结贴分:60                       
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:---------------------
    无满意结贴率:100.00%               无满意结分率:---------------------
    敬礼!
      

  2.   

    int sum =((Integer)hibsession.createQuery("select sum(a.cost) from CdrList as a").iterate().next()).intValue();   
      

  3.   

    select num(字段名) form 类名
    这就是了啊?session.createQuery(),会返回一个object,你转成int或者Integer就是了,LS的就是对的
      

  4.   

    hql方法:
     int sum =((Integer)session.createQuery("select sum(a.property1) from Xxx as a").uniqueResult();   
    criteria方法:
     Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Xxx.class);
     int sum =(Integer)criteria.setProjection(Projections.sum("property1")).uniqueResult();