📄 dialect.java
字号:
package com.set.db.dialect;
/**
* the strategis to deal with different db server for the purposes of being db
* server independent
*
* @author tommy.zeng
*
*/
public abstract class Dialect {
protected Dialect() {
}
public boolean supportsLimitOffset() {
return supportsLimit();
}
/**
* Add a LIMIT clause to the given SQL SELECT
*/
public String getLimitString(String querySelect, boolean hasOffset) {
throw new UnsupportedOperationException("paged queries not supported");
}
public String getLimitString(String querySelect, boolean hasOffset,
int limit) {
return getLimitString(querySelect, hasOffset);
}
public boolean supportsVariableLimit() {
return supportsLimit();
}
/**
* Does the LIMIT clause specify arguments in the "reverse" order limit,
* offset instead of offset, limit?
*
* @return true if the correct order is limit, offset
*/
public boolean bindLimitParametersInReverseOrder() {
return false;
}
/**
* Does the LIMIT clause come at the start of the SELECT statement, rather
* than at the end?
*
* @return true if limit parameters should come before other parameters
*/
public boolean bindLimitParametersFirst() {
return false;
}
/**
* Does the LIMIT clause take a "maximum" row number instead of a total
* number of returned rows?
*/
public boolean useMaxForLimit() {
return false;
}
public boolean supportsLimit() {
return false;
}
public String getQueryCountSql(final String sql) {
int beginIdx = sql.toLowerCase().indexOf("select");
int endIdx = sql.toLowerCase().indexOf("from");
StringBuffer newSql = new StringBuffer(sql.length() + 10);
if (beginIdx >= 0 && endIdx >= 0) {
newSql.append("select count(*) as totalcnt ").append(
sql.substring(endIdx));
}
// remove the order by clause
int orderBy = newSql.toString().toLowerCase().indexOf("order by");
if (orderBy > 0) {
return newSql.substring(0, orderBy - 1);
}
return newSql.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -