我用MyEclipse6.5版本总是出现:typemismatch:cannot convert from int to Integer错误
publicstaticObject[]findPageByHql(finalStringhql,StringhqlCount,finalintpage,finalint...
public static Object[] findPageByHql(final String hql,String hqlCount,final int page,final int pageSize){
List list = new ArrayList();
Long total = new Long(0);
Integer totalPage = 0;//这个地方报的错误
try{
//1.根据hql语句查询指定数据
Query qList = sessionFactory.openSession().createQuery(hql);
qList.setFirstResult((page>0?page-1:page) * pageSize);
qList.setMaxResults(pageSize);
list = qList.list();
//2.根据hql语句查询总记录数
List listCount = findByHql(hqlCount);
if(listCount!=null&&listCount.size()>0){
total = (Long) listCount.get(0);//获取总行数,即总记录数
}
//3.根据总记录数计算出总页数
totalPage = (int)Math.ceil((double)total.longValue()/pageSize);//这个地方也报错
}catch(Exception e){
e.printStackTrace();
}
return new Object[]{list,totalPage,total};
} 展开
List list = new ArrayList();
Long total = new Long(0);
Integer totalPage = 0;//这个地方报的错误
try{
//1.根据hql语句查询指定数据
Query qList = sessionFactory.openSession().createQuery(hql);
qList.setFirstResult((page>0?page-1:page) * pageSize);
qList.setMaxResults(pageSize);
list = qList.list();
//2.根据hql语句查询总记录数
List listCount = findByHql(hqlCount);
if(listCount!=null&&listCount.size()>0){
total = (Long) listCount.get(0);//获取总行数,即总记录数
}
//3.根据总记录数计算出总页数
totalPage = (int)Math.ceil((double)total.longValue()/pageSize);//这个地方也报错
}catch(Exception e){
e.printStackTrace();
}
return new Object[]{list,totalPage,total};
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询