//第一種方法: String hql = "select count(*) from User as user"; Integer count = (Integer)getHibernateTemplate().find(hql).listIterator().next(); return count.intValue();get
//第二種方法: String hql = "select count(*) from User as user"; return ((Integer)getHibernateTemplate().iterate(hql).next()).intValue();it
//第三種方法: String hql = "select count(*) from User as user"; Query query = getHibernateTemplate().createQuery( getSession(),hql); return ((Integer)query.uniqueResult()).intValue();io