hibernate分页:getHibernateTemplate().executeFind(new HibernateCallback() 编译报错, 5
newHibernateCallback()报这里错误,请问是什么原因啊?完成方法如下:publicListqueryByWhCondAndPage(finalStrin...
new HibernateCallback() 报这里错误,请问是什么原因啊?完成方法如下:public List queryByWhCondAndPage(final String whCond,
final Object[] params,final int pageIndex,final int pageSize) {
return getHibernateTemplate().executeFind(new HibernateCallback(whCond, params, pageIndex, pageSize)
{
public Object doInHibernate(Session s) throws HibernateException, SQLException
{
Query query = s.createQuery(whCond);
query.setCacheable(true);
if (params != null)
{
for (int i = 0; i < params.length; i++)
{
query.setParameter(i, params[i]);
}
}
if (pageIndex < 1)
{
query.setFirstResult(0);
query.setMaxResults(pageSize);
}
else {
query.setFirstResult((pageIndex - 1) * pageSize);
query.setMaxResults(pageSize);
}
return query.list();
}
});
} 展开
final Object[] params,final int pageIndex,final int pageSize) {
return getHibernateTemplate().executeFind(new HibernateCallback(whCond, params, pageIndex, pageSize)
{
public Object doInHibernate(Session s) throws HibernateException, SQLException
{
Query query = s.createQuery(whCond);
query.setCacheable(true);
if (params != null)
{
for (int i = 0; i < params.length; i++)
{
query.setParameter(i, params[i]);
}
}
if (pageIndex < 1)
{
query.setFirstResult(0);
query.setMaxResults(pageSize);
}
else {
query.setFirstResult((pageIndex - 1) * pageSize);
query.setMaxResults(pageSize);
}
return query.list();
}
});
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询