public class DbBase extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected Dialect |
dialect |
protected org.springframework.jdbc.core.JdbcTemplate |
jdbcTemplate |
protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate |
namedParameterJdbcTemplate |
| 构造器和说明 |
|---|
DbBase() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
isDataSize(long dataSize)
是否有数据
|
boolean |
isUpdateAndExpectedEqual(long updateRowsNumber,
int expectedValue)
判断更新所影响的行数是否 等于 预期值
若不是预期值,同时 updateRowsNumber > 0 那么将会抛出一个 DbException
|
boolean |
isUpdateAndExpectedGreaterThanEqual(long updateRowsNumber,
int expectedValue)
判断更新所影响的行数是否 大于等于 预期值
若不是预期结果,同时 updateRowsNumber < expectedValue 那么将会抛出一个DbException
|
String |
paramToWhereSql(com.alibaba.fastjson.JSONObject paramJson)
|
protected String |
paramToWhereSql(com.alibaba.fastjson.JSONObject paramJson,
String... conditions)
|
protected void |
paramValidate(String tableName)
参数验证
|
protected void |
paramValidate(String tableName,
com.alibaba.fastjson.JSONObject paramJson)
参数验证
|
protected void |
paramValidate(String tableName,
com.alibaba.fastjson.JSONObject[] paramJsons)
参数验证
|
protected void |
paramValidate(String tableName,
com.alibaba.fastjson.JSONObject paramJson,
String[] conditions)
参数验证
|
protected void |
paramValidate(String tableName,
Long id)
参数验证
|
protected void |
paramValidate(String tableName,
Long id,
String[] fieldName)
参数验证
|
protected void |
paramValidate(String tableName,
String... columnNames)
参数验证
|
protected void |
paramValidate(String tableName,
String whereSql)
参数验证
|
com.alibaba.fastjson.JSONObject |
resultToJson(List<com.alibaba.fastjson.JSONObject> list)
同 DbQuery.queryForJson(String, JSONObject) 的安全查询结果获取
|
<T> T |
resultToObject(List<T> list)
同 DbQuery.queryForObject(String, JSONObject, Class) 的安全查询结果获取
|
void |
updateAndExpectedEqual(long updateRowsNumber,
int expectedValue)
判断更新所影响的行数是否 等于 预期值
若不是预期值,那么将会抛出一个DbException
|
void |
updateAndExpectedGreaterThanEqual(long updateRowsNumber,
int expectedValue)
判断更新所影响的行数是否 大于等于 预期值
若不是预期结果,那么将会抛出一个DbException
|
void |
updateBatchAndExpectedEqual(int[] updateRowsNumberArray,
int expectedValue)
确认批量更新每组参数所影响的行数,是否 全部都等于 同一个预期值
若不是预期值,那么将会抛出一个DbException
|
protected org.springframework.jdbc.core.JdbcTemplate jdbcTemplate
protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate namedParameterJdbcTemplate
protected Dialect dialect
public boolean isDataSize(long dataSize)
dataSize - 数据大小public boolean isUpdateAndExpectedEqual(long updateRowsNumber,
int expectedValue)
若不是预期值,同时 updateRowsNumber > 0 那么将会抛出一个 DbException
updateRowsNumber - 更新所影响的行数expectedValue - 预期值public boolean isUpdateAndExpectedGreaterThanEqual(long updateRowsNumber,
int expectedValue)
若不是预期结果,同时 updateRowsNumber < expectedValue 那么将会抛出一个DbException
updateRowsNumber - 更新所影响的行数expectedValue - 预期值public void updateAndExpectedEqual(long updateRowsNumber,
int expectedValue)
若不是预期值,那么将会抛出一个DbException
updateRowsNumber - 更新所影响的行数expectedValue - 预期值public void updateAndExpectedGreaterThanEqual(long updateRowsNumber,
int expectedValue)
若不是预期结果,那么将会抛出一个DbException
updateRowsNumber - 更新所影响的行数expectedValue - 预期值public void updateBatchAndExpectedEqual(int[] updateRowsNumberArray,
int expectedValue)
若不是预期值,那么将会抛出一个DbException
updateRowsNumberArray - 每组参数更新所影响的行数数组expectedValue - 预期值public com.alibaba.fastjson.JSONObject resultToJson(List<com.alibaba.fastjson.JSONObject> list)
list - DbQuery.queryForList(String, JSONObject) 查询结果public <T> T resultToObject(List<T> list)
T - 泛型list - DbQuery.queryForList(String, JSONObject, Class) 查询结果protected String paramToWhereSql(com.alibaba.fastjson.JSONObject paramJson, String... conditions)
已对 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)public String paramToWhereSql(com.alibaba.fastjson.JSONObject paramJson)
已对 NULL 值进行特殊处理(IS NULL)
已对 List 类型值进行特殊处理(IN (?, ?))
结果示例:
WHERE 1 = 1
AND
param1 = :param1
AND
param2 IS NULL :param2
AND
param3 IN :param3
AND ...
paramJson - 参数protected void paramValidate(String tableName)
tableName - 表名protected void paramValidate(String tableName, String whereSql)
tableName - 表名whereSql - 条件sqlprotected void paramValidate(String tableName, Long id)
tableName - 表名id - 主键IDprotected void paramValidate(String tableName, String... columnNames)
tableName - 表名columnNames - 列名protected void paramValidate(String tableName, Long id, String[] fieldName)
tableName - 表名id - 主键IDfieldName - 字段名称protected void paramValidate(String tableName, com.alibaba.fastjson.JSONObject paramJson)
tableName - 表名paramJson - 参数protected void paramValidate(String tableName, com.alibaba.fastjson.JSONObject[] paramJsons)
tableName - 表名paramJsons - 参数数组Copyright © 2020 Pivotal Software, Inc.. All rights reserved.