private String hql = "select sum(TOTAL_TICKETS) from VoteTeacher";
public long getTeacherListMaxSize(final String hql) {
        long size = 0;
        try {
            size = (Long) this.getHibernateTemplate().execute(
                    new HibernateCallback() {                        public Object doInHibernate(Session session)
                                throws HibernateException, SQLException {
                            Query query = session.createQuery(hql);
                            Long size = (Long) query.list().get(0);
                            return size;                        }
                    });
        } catch (Exception e) {
        }
        return size;
    }
这样查询,返回的结果总是为0!
但是hql语句改为:private String hql = "select count(TOTAL_TICKETS) from VoteTeacher";
可以返回记录的总数不为空!