int num = 0;
Long count = null;
StringBuffer queryTemp=new StringBuffer();
queryTemp.append("SELECT COUNT(*)FROM Salesrecords AS a");
queryTemp.append(" ORDER BY a.id DESC");
count = (Long)getHibernateTemplate().find(queryTemp.toString()).listIterator().next();
##上边返回的是Long,而不是Integer
num = count.intValue();