cn.hutool.db.dialect.impl.SqlServer2012Dialect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hutool-all Show documentation
Show all versions of hutool-all Show documentation
Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
package cn.hutool.db.dialect.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Page;
import cn.hutool.db.dialect.DialectName;
import cn.hutool.db.sql.SqlBuilder;
import cn.hutool.db.sql.Wrapper;
/**
* SQLServer2012 方言
*
* @author loolly
*
*/
public class SqlServer2012Dialect extends AnsiSqlDialect {
private static final long serialVersionUID = -37598166015777797L;
public SqlServer2012Dialect() {
//双引号和中括号适用,双引号更广泛
wrapper = new Wrapper('"');
}
@Override
protected SqlBuilder wrapPageSql(SqlBuilder find, Page page) {
if (false == StrUtil.containsIgnoreCase(find.toString(), "order by")) {
//offset 分页必须要跟在order by后面,没有情况下补充默认排序
find.append(" order by current_timestamp");
}
return find.append(" offset ")
.append(page.getStartPosition())//
.append(" row fetch next ")//row和rows同义词
.append(page.getPageSize())//
.append(" row only");//
}
@Override
public String dialectName() {
return DialectName.SQLSERVER2012.name();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy