/** * Alters the supplied SQL to add paging, such as OFFSET-FETCH. * <p> * The default implementation calls {@link #getPaging(int, int)}. * <p> * The returned SQL must be end in a space if non-empty. * * @param selectToPage the SELECT statement to page, not null * @param offset the OFFSET amount, zero to start from the beginning * @param fetchLimit the FETCH/LIMIT amount, zero to fetch all * @return the updated SELECT, not null */ public String addPaging(String selectToPage, int offset, int fetchLimit) { return selectToPage + (selectToPage.endsWith(" ") ? "" : " ") + getPaging(offset, fetchLimit); }
@Override void toSQL(StringBuilder buf, SqlFragments fragments, SqlParams params, int[] loopIndex) { int offset = extractVariableOrLiteral(params, _offsetVariable); int fetchLimit = extractVariableOrLiteral(params, _fetchVariable); buf.append(fragments.getConfig().getPaging(offset, fetchLimit == Integer.MAX_VALUE ? 0 : fetchLimit)); }