Package org.nutz.dao.pager

Examples of org.nutz.dao.pager.Pager


                                            pager.getOffset()));
        }
    }

    public void formatQuery(Sql sql) {
        Pager pager = sql.getContext().getPager();
        if (null != pager && pager.getPageNumber() > 0) {
            // See http://hsqldb.org/doc/guide/ch09.html#select-section
            sql.setSourceSql(sql.getSourceSql() + String.format(" LIMIT %d offset %d",
                                            pager.getPageSize(),
                                            pager.getOffset()));
        }
    }
View Full Code Here


    public Sqlserver2012JdbcExpert(JdbcExpertConfigFile conf) {
        super(conf);
    }

    public void formatQuery(Pojo pojo) {
        Pager pager = pojo.getContext().getPager();
        // 需要进行分页
        if (null != pager && pager.getPageNumber() > 0)
            pojo.append(Pojos.Items.wrapf(" OFFSET %d ROWS FETCH NEXT %d ROW ONLY", pager.getOffset(), pager.getPageSize()));
    }
View Full Code Here

        if (null != pager && pager.getPageNumber() > 0)
            pojo.append(Pojos.Items.wrapf(" OFFSET %d ROWS FETCH NEXT %d ROW ONLY", pager.getOffset(), pager.getPageSize()));
    }
   
    public void formatQuery(Sql sql) {
        Pager pager = sql.getContext().getPager();
        // 需要进行分页
        if (null != pager && pager.getPageNumber() > 0)
            sql.setSourceSql(sql.getSourceSql() + String.format(" OFFSET %d ROWS FETCH NEXT %d ROW ONLY", pager.getOffset(), pager.getPageSize()));
    }
View Full Code Here

        }
        return super.evalFieldType(mf);
    }

    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()));
        }
    }
View Full Code Here

                                            pager.getOffset() + pager.getPageSize()));
        }
    }

    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);
        }
    }
View Full Code Here

        // 以下代码,就为了该死的游标分页!!
        // -------------------------------------------------
        int startRow = -1;
        int lastRow = -1;
        if (st.getContext().getResultSetType() == ResultSet.TYPE_SCROLL_INSENSITIVE) {
            Pager pager = st.getContext().getPager();
            if (pager != null) {
                startRow = pager.getOffset();
                lastRow = pager.getOffset() + pager.getPageSize();
            }
        }
        // -------------------------------------------------
        // 生成 Sql 语句
        String sql = st.toPreparedStatement();
View Full Code Here

    @Test
    public void test_cnd_pager() {
        pojos.init();
        Sql sql = Sqls.create("select * from t_pet $condition");
        sql.setCondition(Cnd.where("name", "=", "wendal"));
        Pager pager = dao.createPager(1, 20);
        sql.setPager(pager);
        dao.execute(sql);
    }
View Full Code Here

        if (groupBy != null)
          groupBy.setPojo(pojo);
    }

    public void setPager(int pageNumber, int pageSize) {
        pager = new Pager();
        pager.setPageNumber(pageNumber);
        pager.setPageSize(pageSize);
    }
View Full Code Here

            dao.insert(Pet.class,
                       Chain.make("name", "record" + i)
                            .add("nickName",
                                 "Time=" + System.currentTimeMillis()));
        }
        Pager pager = dao.createPager(5, 5);
        pager.setRecordCount(dao.count(Pet.class));
        Sql sql = Sqls.queryEntity("select * from t_pet");
        sql.setEntity(dao.getEntity(Pet.class));
        sql.setPager(pager);
        dao.execute(sql);

View Full Code Here

        _exec(pojo);
        return pojo.getResult();
    }

    public Pager createPager(int pageNumber, int pageSize) {
        Pager pager = new Pager();
        pager.setPageNumber(pageNumber);
        pager.setPageSize(pageSize);
        return pager;
    }
View Full Code Here

TOP

Related Classes of org.nutz.dao.pager.Pager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.