比如select count(*) from user;
那么用query.list().hashCode()返回的是什么?我只想得到count(*),应该怎么得?

解决方案 »

  1.   

    就是用你的sql语句 获得一个list 在获得list的第一项 就行了啊 
      

  2.   


    //统计集团总人数
    public Integer payoffManSum() throws Exception{
    Query q=hibernateSession.createQuery("select count(f.fileInfoId) from FileInfo f where f.fileState=1");
    List payoffList=q.list();
    return (Integer)payoffList.get(0);

    }
      

  3.   

    String countHql = getCountQuery(hql);
    Query query = getSession().createQuery(countHql);
    int total = ((Long)query.uniqueResult()).intValue();
      

  4.   


    为什么我会报java.math.BigInteger
    错误?
      

  5.   

    (BigInteger)强行转换这证明你的数据库中本来就是大字段。
      

  6.   

    String countHql = getCountQuery(hql); 这局是什么额?
      

  7.   

    Query query = getSession().createQuery("select count(*) from user"); 
    int total = ((Long)query.uniqueResult()).intValue();
      

  8.   


    你自己看吧int(11)估计!! public static final String FROM = "from";
    public static final String SELECT_PREFIX = "select count(*) "; public String getCountQuery(String hql){
    int index = hql.indexOf(FROM);
    if(index != -1){
    return SELECT_PREFIX + hql.substring(index);
    }
    throw new ESBException(ConstantZhCnStr.COMBINE_ERROR,"COMMON.COMBINE.ERROR");
    }
      

  9.   


    是11额,那怎么改就不会报java.math.BigInteger ?
      

  10.   


    跟你数据库没关系 你查询出来的count是BigInteger的(谁知道记录总数会有多少条呢..) 虽然可能不会那么长 但是就那么用吧