code: public Page<T> page(String sql, Object[] params, PageRow pageRow) {
          this.beforeCheck();
          Connection conn = getConn();
          try {
              String countSql = useSQL ? "SELECT COUNT(*) FROM (" + sql + ") tmp" : buildCountSQL(sql);
  
              long count = conn.createQuery(countSql)
                      .withParams(params)
                      .executeAndFetchFirst(Long.class);
  
              Page<T> pageBean = new Page<>(count, pageRow.getPageNum(), pageRow.getPageSize());
  
              ifThen(count > 0, () -> {
                  String pageSQL = this.buildPageSQL(sql, pageRow);
                  List<T> list = conn.createQuery(pageSQL)
                          .withParams(params)
                          .setAutoDeriveColumnNames(true)
                          .throwOnMappingFailure(false)
                          .executeAndFetch(modelClass);
  
                  this.setJoin(list);
                  pageBean.setRows(list);
              });
  
              return pageBean;
          } finally {
              this.closeConn(conn);
              this.clean(null);
          }
      }
docs: Paging query results by sql
  
  @param sql     sql statement
  @param params  param values
  @param pageRow page param
  @return Page