All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebean.config.dbplatform.LimitOffsetSqlLimiter Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebean.config.dbplatform;

/**
 * Adds LIMIT OFFSET clauses to a SQL query.
 */
public final class LimitOffsetSqlLimiter implements SqlLimiter {

  @Override
  public SqlLimitResponse limit(SqlLimitRequest request) {
    final var buffer = request.selectDistinctOnSql();
    int maxRows = request.getMaxRows();
    if (maxRows > 0) {
      buffer.append(" limit ").append(maxRows);
    }
    int firstRow = request.getFirstRow();
    if (firstRow > 0) {
      buffer.append(" offset ").append(firstRow);
    }
    return new SqlLimitResponse(request.getDbPlatform().completeSql(buffer.toString(), request.getOrmQuery()));
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy