public class SqlUtils
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static class |
SqlUtils.SqlType
sql语句的类型
|
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
BASE64_FLAG
BASE64的字符串标记
|
构造器和说明 |
---|
SqlUtils() |
限定符和类型 | 方法和说明 |
---|---|
static void |
addOrderBy(kdayun.jsql.statement.select.SelectBody selectBody,
java.util.Map<java.lang.String,java.lang.String> orders)
设置排序
|
static void |
addWhere(kdayun.jsql.statement.select.SelectBody selectBody,
java.util.Map<java.lang.String,java.lang.Object> inParams,
java.util.List<AdvQueryItem> advQuerys,
java.util.List<AdvQueryItem> quickQuerys,
java.util.List<kdayun.jsql.expression.Expression> extraExprs)
组装sql语句
|
static void |
addWhereExpression(kdayun.jsql.statement.select.SelectBody selectBody,
java.util.List<kdayun.jsql.expression.Expression> andFields,
java.util.List<kdayun.jsql.expression.Expression> orFields)
增加where条件
|
(专用程序包) static kdayun.jsql.expression.Expression |
builderBetweenExpression(AdvQueryItem item,
java.util.Map<java.lang.String,java.lang.Object> inParams)
构建 field between xxx to yyyy语句
|
(专用程序包) static kdayun.jsql.expression.Expression |
builderEqualsExpression(AdvQueryItem item,
java.util.Map<java.lang.String,java.lang.Object> inParams)
构建 field=#{field} 语句
|
(专用程序包) static kdayun.jsql.expression.Expression |
builderGreaterThanEqualsExpression(AdvQueryItem item,
java.util.Map<java.lang.String,java.lang.Object> inParams)
构建大于等于语句 field>=#{field}
|
(专用程序包) static kdayun.jsql.expression.Expression |
builderGreaterThanExpression(AdvQueryItem item,
java.util.Map<java.lang.String,java.lang.Object> inParams)
构建大于语句 field>#{field}
|
(专用程序包) static kdayun.jsql.expression.Expression |
builderInExpression(AdvQueryItem item,
java.util.Map<java.lang.String,java.lang.Object> inParams)
构建 field in (...)
|
(专用程序包) static kdayun.jsql.expression.Expression |
builderLikeExpression(AdvQueryItem item,
java.lang.String likeParamName)
构建 like '%#{field}%'
|
(专用程序包) static kdayun.jsql.expression.Expression |
builderLikeExpressionEx(AdvQueryItem item,
java.util.Map<java.lang.String,java.lang.Object> inParams)
构建 like '%#{field}%'
|
static kdayun.jsql.expression.Expression |
buildExpression(kdayun.jsql.statement.select.SelectBody selectBody,
AdvQueryItem item,
java.util.Map<java.lang.String,java.lang.Object> inParams) |
static java.lang.String |
buildSelect(java.lang.String sql,
java.util.Map<java.lang.String,java.lang.Object> inParams,
java.util.List<AdvQueryItem> andFileds,
java.util.List<java.lang.String> orFileds,
java.util.List<AdvQueryItem> likeFields,
java.util.Map<java.lang.String,java.lang.String> orderBys,
java.util.List<kdayun.jsql.expression.Expression> andExprs)
构建sql语句
|
static kdayun.jsql.statement.select.FromItem |
getFromItem(kdayun.jsql.statement.select.SelectBody selectBody)
获取FromItem不支持子查询操作
|
static java.util.List<kdayun.jsql.schema.Table> |
getIntoTables(kdayun.jsql.statement.select.SelectBody selectBody)
获取 into 的tables列表
|
static java.util.List<kdayun.jsql.statement.select.Join> |
getJoins(kdayun.jsql.statement.select.SelectBody selectBody)
获取join
|
static kdayun.jsql.statement.select.Limit |
getLimit(kdayun.jsql.statement.select.SelectBody selectBody)
获取limit 兼容性问题 mysql到时可以 ,Oracle,mssql呢...
|
static java.util.List<kdayun.jsql.statement.select.OrderByElement> |
getOrderBy(kdayun.jsql.statement.select.SelectBody selectBody)
获取排序
|
static java.util.List<kdayun.jsql.statement.select.SelectItem> |
getSelectColumn(kdayun.jsql.statement.select.SelectBody selectBody)
获取查询字段
|
static SqlUtils.SqlType |
getSqlType(java.lang.String sql)
由于jsqlparser没有获取SQL类型的原始工具,并且在下面操作时需要知道SQL类型,所以编写此工具方法
|
static kdayun.jsql.statement.Statement |
getStatement(java.lang.String sql) |
static kdayun.jsql.statement.select.SubSelect |
getSubSelect(kdayun.jsql.statement.select.SelectBody selectBody)
获取子查询
|
static java.util.List<java.lang.String> |
getTableList(kdayun.jsql.statement.select.Select statement)
获取表名
|
static boolean |
isMultiSubSelect(kdayun.jsql.statement.select.SelectBody selectBody)
判断是否多嵌套查询
|
(专用程序包) static boolean |
needNewParamName(java.lang.String paramName,
java.lang.Object value,
java.util.Map<java.lang.String,java.lang.Object> inParams)
是否要取一个新的参数名字.
|
static void |
setIntoTables(kdayun.jsql.statement.select.SelectBody selectBody,
java.util.List<kdayun.jsql.schema.Table> tables)
设置into 的tables列表
|
static void |
setLimit(kdayun.jsql.statement.select.SelectBody selectBody,
long l)
设置limit 兼容性问题 mysql到时可以,Oracle,mssql呢...
|
public static final java.lang.String BASE64_FLAG
public static SqlUtils.SqlType getSqlType(java.lang.String sql) throws kdayun.jsql.JSQLParserException
sql
- sql语句kdayun.jsql.JSQLParserException
- 语句出现语法错误public static kdayun.jsql.statement.Statement getStatement(java.lang.String sql) throws kdayun.jsql.JSQLParserException
kdayun.jsql.JSQLParserException
public static java.util.List<java.lang.String> getTableList(kdayun.jsql.statement.select.Select statement)
statement
- Select's statementpublic static java.util.List<kdayun.jsql.statement.select.Join> getJoins(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static java.util.List<kdayun.jsql.schema.Table> getIntoTables(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static void setIntoTables(kdayun.jsql.statement.select.SelectBody selectBody, java.util.List<kdayun.jsql.schema.Table> tables)
selectBody
- 语句的SelectBodytables
- 表public static kdayun.jsql.statement.select.Limit getLimit(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static void setLimit(kdayun.jsql.statement.select.SelectBody selectBody, long l)
selectBody
- 语句的SelectBodyl
- 数量public static kdayun.jsql.statement.select.FromItem getFromItem(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static kdayun.jsql.statement.select.SubSelect getSubSelect(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static boolean isMultiSubSelect(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static java.util.List<kdayun.jsql.statement.select.SelectItem> getSelectColumn(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static java.util.List<kdayun.jsql.statement.select.OrderByElement> getOrderBy(kdayun.jsql.statement.select.SelectBody selectBody)
selectBody
- 语句的SelectBodypublic static void addOrderBy(kdayun.jsql.statement.select.SelectBody selectBody, java.util.Map<java.lang.String,java.lang.String> orders) throws java.lang.Exception
selectBody
- 语句的SelectBodyorders
- 排序Mapjava.lang.Exception
- 出错会抛出异常public static void addWhereExpression(kdayun.jsql.statement.select.SelectBody selectBody, java.util.List<kdayun.jsql.expression.Expression> andFields, java.util.List<kdayun.jsql.expression.Expression> orFields)
selectBody
- 语句的SelectBodyandFields
- and字段listorFields
- or条件的字段listpublic static kdayun.jsql.expression.Expression buildExpression(kdayun.jsql.statement.select.SelectBody selectBody, AdvQueryItem item, java.util.Map<java.lang.String,java.lang.Object> inParams) throws java.lang.Exception
java.lang.Exception
public static void addWhere(kdayun.jsql.statement.select.SelectBody selectBody, java.util.Map<java.lang.String,java.lang.Object> inParams, java.util.List<AdvQueryItem> advQuerys, java.util.List<AdvQueryItem> quickQuerys, java.util.List<kdayun.jsql.expression.Expression> extraExprs) throws java.lang.Exception
selectBody
- select 主体 不包含whereinParams
- 输入参数advQuerys
- 高级查询条件quickQuerys
- 快速查询条件extraExprs
- 额外的查询条件java.lang.Exception
- 出错会抛出异常static kdayun.jsql.expression.Expression builderGreaterThanExpression(AdvQueryItem item, java.util.Map<java.lang.String,java.lang.Object> inParams)
columnName
- 列名static boolean needNewParamName(java.lang.String paramName, java.lang.Object value, java.util.Map<java.lang.String,java.lang.Object> inParams)
paramName
- 参数名value
- 值inParams
- 初始化参数static kdayun.jsql.expression.Expression builderGreaterThanEqualsExpression(AdvQueryItem item, java.util.Map<java.lang.String,java.lang.Object> inParams)
columnName
- 列名static kdayun.jsql.expression.Expression builderBetweenExpression(AdvQueryItem item, java.util.Map<java.lang.String,java.lang.Object> inParams) throws java.lang.Exception
columnName
- 列名java.lang.Exception
- 出错会抛出异常static kdayun.jsql.expression.Expression builderInExpression(AdvQueryItem item, java.util.Map<java.lang.String,java.lang.Object> inParams) throws kdayun.jsql.JSQLParserException
columnName
- 列名kdayun.jsql.JSQLParserException
- 语句出现语法错误static kdayun.jsql.expression.Expression builderEqualsExpression(AdvQueryItem item, java.util.Map<java.lang.String,java.lang.Object> inParams)
columnName
- 列名static kdayun.jsql.expression.Expression builderLikeExpressionEx(AdvQueryItem item, java.util.Map<java.lang.String,java.lang.Object> inParams) throws java.sql.SQLException
columnName
- 列名likeParamName
- java.sql.SQLException
- 出错抛出数据库异常static kdayun.jsql.expression.Expression builderLikeExpression(AdvQueryItem item, java.lang.String likeParamName) throws java.sql.SQLException
columnName
- 列名likeParamName
- java.sql.SQLException
- 出错抛出数据库异常public static java.lang.String buildSelect(java.lang.String sql, java.util.Map<java.lang.String,java.lang.Object> inParams, java.util.List<AdvQueryItem> andFileds, java.util.List<java.lang.String> orFileds, java.util.List<AdvQueryItem> likeFields, java.util.Map<java.lang.String,java.lang.String> orderBys, java.util.List<kdayun.jsql.expression.Expression> andExprs) throws java.lang.Exception
sql
- 初始的sql语句. 一般是dataSource的sql的预设的语句inParams
- 输入参数andFileds
- and查询字段orFileds
- or查询字段likeFields
- like查询字段orderBys
- 排序andExprs
- 额外增加的and条件java.lang.Exception
- 出错会抛出异常