class SqlWindowingPagingQueryProvider extends AbstractSqlPagingQueryProvider {

	@Override
	public String generateFirstPageQuery(int pageSize) {<FILL_FUNCTION_BODY>}

	protected String getOrderedQueryAlias() {
		return "";
	}

	protected Object getSubQueryAlias() {
		return "AS TMP_SUB ";
	}

	protected Object extractTableAlias() {
		String alias = String.valueOf(getSubQueryAlias());
		if (StringUtils.hasText(alias) && alias.toUpperCase().startsWith("AS")) {
			alias = alias.substring(3).trim() + ".";
		}
		return alias;
	}

	@Override
	public String generateRemainingPagesQuery(int pageSize) {
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT * FROM ( ");
		sql.append("SELECT ")
			.append(StringUtils.hasText(getOrderedQueryAlias()) ? getOrderedQueryAlias() + ".*, " : "*, ");
		sql.append("ROW_NUMBER() OVER (").append(getOverClause());
		sql.append(") AS ROW_NUMBER");
		sql.append(getOverSubstituteClauseStart());
		sql.append(" FROM ").append(getFromClause());
		if (getWhereClause() != null) {
			sql.append(" WHERE ");
			sql.append(getWhereClause());
		}

		sql.append(getGroupClause() == null ? "" : " GROUP BY " + getGroupClause());
		sql.append(getOverSubstituteClauseEnd());
		sql.append(") ")
			.append(getSubQueryAlias())
			.append("WHERE ")
			.append(extractTableAlias())
			.append("ROW_NUMBER <= ")
			.append(pageSize);
		sql.append(" AND ");
		SqlPagingQueryUtils.buildSortConditions(this, sql);
		sql.append(" ORDER BY ").append(SqlPagingQueryUtils.buildSortClause(this));

		return sql.toString();
	}

	protected String getOverClause() {
		StringBuilder sql = new StringBuilder();

		sql.append(" ORDER BY ").append(buildSortClause(this));

		return sql.toString();
	}

	protected String getOverSubstituteClauseStart() {
		return "";
	}

	protected String getOverSubstituteClauseEnd() {
		return "";
	}

	/**
	 * Generates ORDER BY attributes based on the sort keys.
	 * @param provider the paging query provider
	 * @return a String that can be appended to an ORDER BY clause.
	 */
	private String buildSortClause(AbstractSqlPagingQueryProvider provider) {
		return SqlPagingQueryUtils.buildSortClause(provider.getSortKeysWithoutAliases());
	}

}

		StringBuilder sql = new StringBuilder();
		sql.append("SELECT * FROM ( ");
		sql.append("SELECT ")
			.append(StringUtils.hasText(getOrderedQueryAlias()) ? getOrderedQueryAlias() + ".*, " : "*, ");
		sql.append("ROW_NUMBER() OVER (").append(getOverClause());
		sql.append(") AS ROW_NUMBER");
		sql.append(getOverSubstituteClauseStart());
		sql.append(" FROM ")
			.append(getFromClause())
			.append(getWhereClause() == null ? "" : " WHERE " + getWhereClause());
		sql.append(getGroupClause() == null ? "" : " GROUP BY " + getGroupClause());
		sql.append(getOverSubstituteClauseEnd());
		sql.append(") ")
			.append(getSubQueryAlias())
			.append("WHERE ")
			.append(extractTableAlias())
			.append("ROW_NUMBER <= ")
			.append(pageSize);
		sql.append(" ORDER BY ").append(SqlPagingQueryUtils.buildSortClause(this));

		return sql.toString();
	
<methods>public non-sealed void <init>() ,public abstract java.lang.String generateFirstPageQuery(int) ,public abstract java.lang.String generateRemainingPagesQuery(int) ,public java.lang.String getGroupClause() ,public int getParameterCount() ,public java.lang.String getSortKeyPlaceHolder(java.lang.String) ,public Map<java.lang.String,org.springframework.batch.item.database.Order> getSortKeys() ,public Map<java.lang.String,org.springframework.batch.item.database.Order> getSortKeysWithoutAliases() ,public void init(javax.sql.DataSource) throws java.lang.Exception,public boolean isUsingNamedParameters() ,public void setFromClause(java.lang.String) ,public void setGroupClause(java.lang.String) ,public void setSelectClause(java.lang.String) ,public void setSortKeys(Map<java.lang.String,org.springframework.batch.item.database.Order>) ,public void setWhereClause(java.lang.String) <variables>private java.lang.String fromClause,private java.lang.String groupClause,private int parameterCount,private java.lang.String selectClause,private Map<java.lang.String,org.springframework.batch.item.database.Order> sortKeys,private boolean usingNamedParameters,private java.lang.String whereClause