日期:2014-05-20 浏览次数:20798 次
public pageBean seachProductByBrank(int pageSize, int currentLPage, String product_Brank, String product_itemName) { final String hql = "from " + OgrilProducts.class.getName() + " where product_Brank='" + product_Brank + "' and product_itemName='" + product_itemName + "' order by product_registerDate desc"; int allRow = this.getAllRowCount(hql);// 总记录数 int totalPage = pageBean.countTotalpage(pageSize, allRow);// 总页数 final int offset = pageBean.countOffset(pageSize, currentLPage);// 当前页开始记录 final int length = pageSize; final int currentPage = pageBean.countCurrentPage(currentLPage); List list = this.queryForPage(hql, offset, length);// 记录 // 把分页信息保存到Bean中 pageBean pagebean = new pageBean(); pagebean.setPageSize(pageSize); pagebean.setCurrentPage(currentPage); pagebean.setAllRow(allRow); pagebean.setTotalPage(totalPage); pagebean.setList(list); return pagebean; }
List list = this.queryForPage(hql, offset, length);// 记录
------解决方案--------------------
用DISTINCT可以解決大部份問題
String hql = "select distinct(obj.number),obj.a,obj.b from Object obj where ...";