io.ebean.config.dbplatform.sqlserver.SqlServerBasicSqlLimiter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebean.config.dbplatform.sqlserver;
import io.ebean.config.dbplatform.BasicSqlLimiter;
/**
* SQL Server 2012 style limiter for raw sql.
*/
public class SqlServerBasicSqlLimiter implements BasicSqlLimiter {
@Override
public String limit(String dbSql, int firstRow, int maxRows) {
StringBuilder sb = new StringBuilder(50 + dbSql.length());
sb.append(dbSql);
if (!dbSql.toLowerCase().contains("order by")) {
sb.append(" order by 1 ");
}
sb.append(" ").append("offset");
sb.append(" ").append(firstRow).append(" rows");
if (maxRows > 0) {
sb.append(" fetch next ").append(maxRows).append(" rows only");
}
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy