项目中使用了公司封装的数据库操作jar,但Hibernate分页效率总是不高,怀疑底层是先查后分页的情况,底子不好 各位大神劳烦看下 是先查询后分的页吗?(请先回答此问题)
有什么优化建议没?
sqlstr 为sql语句,mapps为条件
public Map getList(String sqlstr, Map mapps, int iPageNo, int iPageSize) throws DAOException
{
HibernateCallback callback = new HibernateCallback(this, sqlstr, mapps, iPageNo, iPageSize) { final HibernatePersistenceManager this$0;
private final String val$sqlstr;
private final Map val$mapps;
private final int val$iPageNo;
private final int val$iPageSize;
public Object doInHibernate() throws HibernateException, SQLException { Query query = this.this$0.getHibernateTemplate().createQuery(session,
this.val$sqlstr);
List list = new ArrayList();
if ((this.val$mapps != null) && (!(this.val$mapps.isEmpty()))) {
Iterator it = this.val$mapps.keySet().iterator();
while (it.hasNext()) {
String numStr = (String)it.next();
int num = Integer.parseInt(numStr);
query.setParameter(num, this.val$mapps.get(numStr));
}
}
this.this$0.setPageNo(this.val$iPageNo);
this.this$0.setPageSize(this.val$iPageSize);
if ((this.val$mapps != null) && (!(this.val$mapps.isEmpty())))
this.this$0.setQueryPage(query, this.val$mapps);
else
this.this$0.setQueryPage(query);
list = query.list();
Map map = new HashMap();
map.put("RecTotal", this.this$0.getRecTotal());
map.put("PageTotal", this.this$0.getPageTotal());
map.put("List", list);
return map;
}
};
return ((Map)getHibernateTemplate().execute(callback));
}