String hql = "select count(*) from ( select companyname,tasktype,count(*) from ViewMczdfgCustom " + "where 1=1 ) tt"; Query q = this.getSession().createQuery(hql); List countlist = getHibernateTemplate().find(hql); //都要报错