com.github.chengyuxing.sql.page.impl.PGPageHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rabbit-sql Show documentation
Show all versions of rabbit-sql Show documentation
Light wrapper of JDBC, support ddl, dml, query, plsql/procedure/function, transaction and manage sql
file.
package com.github.chengyuxing.sql.page.impl;
import com.github.chengyuxing.sql.Args;
import com.github.chengyuxing.sql.page.PageHelper;
/**
* PostgreSQL page helper, e.g.
*
* select * from ... limit :{@link #START_NUM_KEY} offset :{@link #END_NUM_KEY};
*
*
* @see #pagedArgs()
*/
public class PGPageHelper extends PageHelper {
public int limit() {
return pageSize;
}
public int offset() {
if (recordCount == 0) {
return 0;
}
return (pageNumber - 1) * pageSize;
}
@Override
public String pagedSql(String sql) {
return sql + " LIMIT " + limit() + " OFFSET " + offset();
}
@Override
public Args pagedArgs() {
return Args.of(START_NUM_KEY, limit()).add(END_NUM_KEY, offset());
}
}