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

com.zhuang.data.pagination.MySqlPaging Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package com.zhuang.data.pagination;

import com.zhuang.data.util.SqlUtils;

public class MySqlPaging extends DbPaging {

    @Override
    public String getPageSql(String sql, String orderClause, int startRowIndex, int rowCount) {
        sql = SqlUtils.removeOrderByClause(sql);
        StringBuilder stringBuilder = new StringBuilder();
        if (orderClause != null && !orderClause.isEmpty()) {
            orderClause = "order by " + orderClause;
            stringBuilder.append(sql).append(" ").append(orderClause).append(" ").append("limit ")
                    .append(startRowIndex - 1).append(",").append(rowCount);
            return stringBuilder.toString();
        }
        throw new RuntimeException("Paged query must set orderBy Clause");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy