コード例 #1
0
  @Override
  @SuppressWarnings("unchecked")
  public PageList<DC> listPage(int pageNo, int pageSize) {
    Criteria countCriteria = entityDao.getCriteria();
    Criteria listCriteria = entityDao.getCriteria();

    //		listCriteria.createAlias("account", "a");
    //		listCriteria.add(Restrictions.eq("a.id", accountId));
    listCriteria.setFirstResult((pageNo - 1) * pageSize);
    listCriteria.setMaxResults(pageSize);
    List<DC> items = listCriteria.list();
    countCriteria.setProjection(Projections.rowCount());
    Integer count = Integer.parseInt(countCriteria.uniqueResult().toString());
    return PageListUtil.getPageList(count, pageNo, items, pageSize);
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  public PageList<Organization> listPage(String name, int pageNo, int pageSize) {
    Criteria countCriteria = entityDao.getCriteria();
    Criteria listCriteria = entityDao.getCriteria();

    if (name != null && !name.isEmpty()) {
      countCriteria.add(Restrictions.eq("name", name));
      listCriteria.add(Restrictions.eq("name", name));
    }

    listCriteria.setFirstResult((pageNo - 1) * pageSize);
    listCriteria.setMaxResults(pageSize);
    List<Organization> items = listCriteria.list();
    countCriteria.setProjection(Projections.rowCount());
    Integer count = Integer.parseInt(countCriteria.uniqueResult().toString());
    return PageListUtil.getPageList(count, pageNo, items, pageSize);
  }