hibernate3 + oracle + ext 分页示例1

来源:百度文库 编辑:神马文学网 时间:2019/12/08 11:43:18
ext 传入start 及 limt 二个参数
HttpServletRequest request = ServletActionContext.getRequest();
String start = request.getParameter("start");
String limit = request.getParameter("limit");
一:oracle(t.rownum  在别的数据库有没有不知道没测试过)
hql 进行查询
/**
* 概据JBPM流程定义ID查找流程定 义相关信息
* @param deploymentId,strart 从第几条开始查,limt 查到第几条
* @return
*/
public List findPdByDeploymentId(long deploymentId,int strart,int limt) {
List list= new ArrayList();
String hql = "from WorkFlowPojo t where t.deploymentId = '"+deploymentId+"' and t.status=1 t.rownum>="+strart+" and t.rownum <="+limt;
return list = getHibernateTemplate().find(hql);
}
sql 进行查询
@param strart 从第几条开始查,limt 查到第几条
select t.fid,t.columnlist,t.varcolumnlist from JBPM4_FORM_ACTIVITY t where t.rownum>="+strart+" and t.rownum <="+limt
二:hibernate session进行查询
/**分页查找*/
public List findPagedAll(int start, int limit) {
log.debug("分页查找");
try {
String queryString = "from ReporttypePojo";
Query queryObject = getSession().createQuery(queryString);
queryObject.setFirstResult(start);
queryObject.setMaxResults(limit);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}