Esempio n. 1
0
 public void formatQuery(Sql sql) {
   Pager pager = sql.getContext().getPager();
   if (null != pager && pager.getPageNumber() > 0) {
     sql.setSourceSql(
         sql.getSourceSql()
             + String.format(" LIMIT %d OFFSET %d", pager.getPageSize(), pager.getOffset()));
   }
 }
Esempio n. 2
0
 public void formatQuery(Sql sql) {
   Pager pager = sql.getContext().getPager();
   if (null != pager && pager.getPageNumber() > 0) {
     String pre = "SELECT * FROM (SELECT ROW_NUMBER() OVER() AS ROWNUM, T.* FROM (";
     String last =
         String.format(
             ") T) AS A WHERE ROWNUM BETWEEN %d AND %d",
             pager.getOffset() + 1, pager.getOffset() + pager.getPageSize());
     sql.setSourceSql(pre + sql.getSourceSql() + last);
   }
 }
Esempio n. 3
0
 public void formatQuery(Pojo pojo) {
   Pager pager = pojo.getContext().getPager();
   // 需要进行分页
   if (null != pager && pager.getPageNumber() > 0) {
     // 之前插入
     pojo.insertFirst(
         Pojos.Items.wrap(
             "SELECT * FROM (" + "SELECT ROW_NUMBER() OVER() AS ROWNUM, " + "T.* FROM ("));
     // 之后插入
     pojo.append(
         Pojos.Items.wrapf(
             ") T) AS A WHERE ROWNUM BETWEEN %d AND %d",
             pager.getOffset() + 1, pager.getOffset() + pager.getPageSize()));
   }
 }
Esempio n. 4
0
 public void formatQuery(Pojo pojo) {
   Pager pager = pojo.getContext().getPager();
   // 需要进行分页
   if (null != pager && pager.getPageNumber() > 0)
     pojo.append(Pojos.Items.wrapf(" LIMIT %d OFFSET %d", pager.getPageSize(), pager.getOffset()));
 }