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

io.github.biezhi.anima.dialect.MySQLDialect Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
package io.github.biezhi.anima.dialect;

import io.github.biezhi.anima.core.SQLParams;
import io.github.biezhi.anima.page.PageRow;

/**
 * MySQL dialect
 *
 * @author biezhi
 * @date 2018/3/17
 */
public class MySQLDialect implements Dialect {

    @Override
    public String paginate(SQLParams sqlParams) {
        PageRow pageRow  = sqlParams.getPageRow();
        int     limit    = pageRow.getPageSize();
        int     offset   = limit * (pageRow.getPageNum() - 1);
        String  limitSQL = " LIMIT " + offset + "," + limit;

        StringBuilder sql = new StringBuilder();
        sql.append(select(sqlParams)).append(limitSQL);
        return sql.toString();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy