use of org.nutz.dao.pager.Pager in project nutz by nutzam.
the class Sqlserver2005JdbcExpert method formatQuery.
public void formatQuery(Pojo pojo) {
Pager pager = pojo.getContext().getPager();
if (null != pager && pager.getPageNumber() > 0) {
// -----------------------------------------------------
// TODO XXX 这个写法灰常暴力!!But , it works!!!! 期待更好的写法
PItem pi = pojo.getItem(0);
StringBuilder sb = new StringBuilder();
pi.joinSql(pojo.getEntity(), sb);
String str = sb.toString();
if (str.trim().toLowerCase().startsWith("select")) {
pojo.setItem(0, Pojos.Items.wrap(str.substring(6)));
} else
// 以免出错.
return;
pojo.insertFirst(Pojos.Items.wrapf("select * from(select row_number()over(order by __tc__)__rn__,* from(select top %d 0 __tc__, ", pager.getOffset() + pager.getPageSize()));
pojo.append(Pojos.Items.wrapf(")t)tt where __rn__ > %d order by __rn__", pager.getOffset()));
}
}
use of org.nutz.dao.pager.Pager in project nutz by nutzam.
the class OracleJdbcExpert method formatQuery.
public void formatQuery(Pojo pojo) {
Pager pager = pojo.getContext().getPager();
// 需要进行分页
if (null != pager && pager.getPageNumber() > 0) {
pojo.insertFirst(Pojos.Items.wrap("SELECT * FROM (SELECT T.*, ROWNUM RN FROM ("));
pojo.append(Pojos.Items.wrapf(") T WHERE ROWNUM <= %d) WHERE RN > %d", pager.getOffset() + pager.getPageSize(), pager.getOffset()));
}
}
use of org.nutz.dao.pager.Pager in project nutz by nutzam.
the class OracleJdbcExpert method formatQuery.
@Override
public void formatQuery(Sql sql) {
Pager pager = sql.getContext().getPager();
// 需要进行分页
if (null != pager && pager.getPageNumber() > 0) {
String pre = "SELECT * FROM (SELECT T.*, ROWNUM RN FROM (";
String last = String.format(") T WHERE ROWNUM <= %d) WHERE RN > %d", pager.getOffset() + pager.getPageSize(), pager.getOffset());
sql.setSourceSql(pre + sql.getSourceSql() + last);
}
}
use of org.nutz.dao.pager.Pager in project nutz by nutzam.
the class Db2JdbcExpert method formatQuery.
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);
}
}
use of org.nutz.dao.pager.Pager in project nutz by nutzam.
the class SimpleCriteria method setPager.
public void setPager(int pageNumber, int pageSize) {
pager = new Pager();
pager.setPageNumber(pageNumber);
pager.setPageSize(pageSize);
}
Aggregations