hibernate返回Integer

StringBuffer sql = new StringBuffer("SELECT count(*) as  maxId  FROM " +tableName+" where fk_compay_id="+companyId+"");
Integer maxId = (Integer) (getSessionFactory().getCurrentSession().createSQLQuery(sql.toString()).addScalar("maxId", StandardBasicTypes.INTEGER)).uniqueResult();
return maxId;
原文地址:https://www.cnblogs.com/liclBlog/p/15349549.html