类 DbBase
- java.lang.Object
-
- ai.yue.library.data.jdbc.client.DbBase
-
- 直接已知子类:
AnsiSqlDialect,Db
public class DbBase extends Object
SQL优化型数据库操作
Created by sunJinChuan on 2016/6/6- 从以下版本开始:
- 0.0.1
-
-
字段概要
字段 修饰符和类型 字段 说明 protected Dialectdialectprotected org.springframework.jdbc.core.JdbcTemplatejdbcTemplateprotected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplatenamedParameterJdbcTemplate
-
构造器概要
构造器 构造器 说明 DbBase()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleanisDataSize(long dataSize)是否有数据booleanisUpdateAndExpectedEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 等于 预期值booleanisUpdateAndExpectedGreaterThanEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 大于等于 预期值StringparamToWhereSql(com.alibaba.fastjson.JSONObject paramJson)绝对条件查询参数whereSql化protected StringparamToWhereSql(com.alibaba.fastjson.JSONObject paramJson, String... conditions)绝对条件查询参数whereSql化protected voidparamValidate(String tableName)参数验证protected voidparamValidate(String tableName, com.alibaba.fastjson.JSONObject paramJson)参数验证protected voidparamValidate(String tableName, com.alibaba.fastjson.JSONObject[] paramJsons)参数验证protected voidparamValidate(String tableName, com.alibaba.fastjson.JSONObject paramJson, String[] conditions)参数验证protected voidparamValidate(String tableName, Long id)参数验证protected voidparamValidate(String tableName, Long id, String[] fieldName)参数验证protected voidparamValidate(String tableName, String whereSql)参数验证protected voidparamValidate(String tableName, String... columnNames)参数验证com.alibaba.fastjson.JSONObjectresultToJson(List<com.alibaba.fastjson.JSONObject> list)同 DbQuery.queryForJson(String, JSONObject) 的安全查询结果获取<T> TresultToObject(List<T> list)同 DbQuery.queryForObject(String, JSONObject, Class) 的安全查询结果获取voidupdateAndExpectedEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 等于 预期值voidupdateAndExpectedGreaterThanEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 大于等于 预期值voidupdateBatchAndExpectedEqual(int[] updateRowsNumberArray, int expectedValue)确认批量更新每组参数所影响的行数,是否 全部都等于 同一个预期值
-
-
-
字段详细资料
-
jdbcTemplate
protected org.springframework.jdbc.core.JdbcTemplate jdbcTemplate
-
namedParameterJdbcTemplate
protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate namedParameterJdbcTemplate
-
dialect
protected Dialect dialect
-
-
方法详细资料
-
isDataSize
public boolean isDataSize(long dataSize)
是否有数据- 参数:
dataSize- 数据大小- 返回:
- 是否 <= 0
-
isUpdateAndExpectedEqual
public boolean isUpdateAndExpectedEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 等于 预期值若不是预期值,同时 updateRowsNumber > 0 那么将会抛出一个 DbException
- 参数:
updateRowsNumber- 更新所影响的行数expectedValue- 预期值- 返回:
- 是否 等于 预期值
-
isUpdateAndExpectedGreaterThanEqual
public boolean isUpdateAndExpectedGreaterThanEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 大于等于 预期值若不是预期结果,同时 updateRowsNumber < expectedValue 那么将会抛出一个DbException
- 参数:
updateRowsNumber- 更新所影响的行数expectedValue- 预期值- 返回:
- 是否 大于等于 预期值
-
updateAndExpectedEqual
public void updateAndExpectedEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 等于 预期值若不是预期值,那么将会抛出一个DbException
- 参数:
updateRowsNumber- 更新所影响的行数expectedValue- 预期值
-
updateAndExpectedGreaterThanEqual
public void updateAndExpectedGreaterThanEqual(long updateRowsNumber, int expectedValue)判断更新所影响的行数是否 大于等于 预期值若不是预期结果,那么将会抛出一个DbException
- 参数:
updateRowsNumber- 更新所影响的行数expectedValue- 预期值
-
updateBatchAndExpectedEqual
public void updateBatchAndExpectedEqual(int[] updateRowsNumberArray, int expectedValue)确认批量更新每组参数所影响的行数,是否 全部都等于 同一个预期值若不是预期值,那么将会抛出一个DbException
- 参数:
updateRowsNumberArray- 每组参数更新所影响的行数数组expectedValue- 预期值
-
resultToJson
public com.alibaba.fastjson.JSONObject resultToJson(List<com.alibaba.fastjson.JSONObject> list)
同 DbQuery.queryForJson(String, JSONObject) 的安全查询结果获取- 参数:
list- DbQuery.queryForList(String, JSONObject) 查询结果- 返回:
- JSON数据
-
resultToObject
public <T> T resultToObject(List<T> list)
同 DbQuery.queryForObject(String, JSONObject, Class) 的安全查询结果获取- 类型参数:
T- 泛型- 参数:
list- DbQuery.queryForList(String, JSONObject, Class) 查询结果- 返回:
- POJO对象
-
paramToWhereSql
protected String paramToWhereSql(com.alibaba.fastjson.JSONObject paramJson, String... conditions)
绝对条件查询参数whereSql化已对 NULL 值进行特殊处理(IS NULL)
已对 List 类型值进行特殊处理(IN (?, ?))
结果示例:
WHERE 1 = 1
AND
param1 = :param1
AND
param2 IS NULL :param2
AND
param3 IN :param3
AND ...- 参数:
paramJson- 参数conditions- where条件(对应paramJson key)- 返回:
- whereSql
-
paramToWhereSql
public String paramToWhereSql(com.alibaba.fastjson.JSONObject paramJson)
绝对条件查询参数whereSql化已对 NULL 值进行特殊处理(IS NULL)
已对 List 类型值进行特殊处理(IN (?, ?))
结果示例:
WHERE 1 = 1
AND
param1 = :param1
AND
param2 IS NULL :param2
AND
param3 IN :param3
AND ...- 参数:
paramJson- 参数- 返回:
- whereSql
-
paramValidate
protected void paramValidate(String tableName)
参数验证- 参数:
tableName- 表名
-
paramValidate
protected void paramValidate(String tableName, String whereSql)
参数验证- 参数:
tableName- 表名whereSql- 条件sql
-
paramValidate
protected void paramValidate(String tableName, Long id)
参数验证- 参数:
tableName- 表名id- 主键ID
-
paramValidate
protected void paramValidate(String tableName, String... columnNames)
参数验证- 参数:
tableName- 表名columnNames- 列名
-
paramValidate
protected void paramValidate(String tableName, Long id, String[] fieldName)
参数验证- 参数:
tableName- 表名id- 主键IDfieldName- 字段名称
-
paramValidate
protected void paramValidate(String tableName, com.alibaba.fastjson.JSONObject paramJson)
参数验证- 参数:
tableName- 表名paramJson- 参数
-
paramValidate
protected void paramValidate(String tableName, com.alibaba.fastjson.JSONObject[] paramJsons)
参数验证- 参数:
tableName- 表名paramJsons- 参数数组
-
-