public abstract class GeneralJsonObjectDao extends Object implements JsonObjectDao
| 限定符和类型 | 类和说明 |
|---|---|
class |
GeneralJsonObjectDao.JSONObjectComparator |
| 限定符和类型 | 字段和说明 |
|---|---|
protected static org.slf4j.Logger |
logger |
static String |
SELF_ORDER_BY
用户自定义排序描述, 放到 filterDesc 中
|
static String |
TABLE_SORT_FIELD
用户自定义排序字段 , 放到 filterDesc 中
|
static String |
TABLE_SORT_ORDER
用户自定义排序字段的排序顺序 , 放到 filterDesc 中
|
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
buildCountSqlByProperties(TableInfo tableInfo,
Map<String,Object> properties) |
static String |
buildFieldSql(TableInfo ti,
String alias,
int builderType)
返回 sql 语句 和 属性名数组
|
static org.apache.commons.lang3.tuple.Pair<String,TableField[]> |
buildFieldSqlWithFields(TableInfo mapInfo,
String alias,
boolean excludeLazy) |
static String |
buildFilterSql(TableInfo ti,
String alias,
Collection<String> properties) |
static String |
buildFilterSqlByPk(TableInfo ti,
String alias) |
static String |
buildInsertSql(TableInfo ti,
Collection<String> fields) |
static String |
buildPartFieldSql(TableInfo ti,
Collection<String> fields,
String alias,
boolean withPk)
返回 sql 语句 和 属性名数组
|
static org.apache.commons.lang3.tuple.Pair<String,TableField[]> |
buildPartFieldSqlWithFields(TableInfo ti,
Collection<String> fields,
String alias,
boolean withPk)
返回 sql 语句 和 属性名数组
|
static org.apache.commons.lang3.tuple.Pair<String,TableField[]> |
buildSelectSqlWithFields(TableInfo mapInfo,
String alias,
boolean excludeLazy,
String filterSql,
boolean withOrderBy,
String orderSql)
返回 sql 语句 和 属性名数组
|
static String |
buildUpdateSql(TableInfo ti,
Collection<String> fields)
返回更新语句 update ,如果返回null表示 没有更新的内容
|
boolean |
checkHasAllPkColumns(Map<String,Object> properties) |
static boolean |
checkHasAllPkColumns(TableInfo tableInfo,
Map<String,Object> properties) |
static boolean |
checkNeedUpdate(Map<String,Object> oldObject,
Map<String,Object> newObject)
比较两个对象,判断是否需要更新,这个仅用于只更新有值的字段
|
static GeneralJsonObjectDao |
createJsonObjectDao(Connection conn) |
static GeneralJsonObjectDao |
createJsonObjectDao(Connection conn,
TableInfo tableInfo) |
static GeneralJsonObjectDao |
createJsonObjectDao(DBType dbtype,
Connection conn) |
int |
deleteObjectById(Object keyValue)
删除,单主键
|
int |
deleteObjects(List<Object> objects)
批量删除
|
int |
deleteObjectsAsTabulation(Map<String,Object> properties)
根据外键批量删除,符合外键
|
int |
deleteObjectsAsTabulation(String propertyName,
Object propertyValue)
根据外键批量删除,单外键
|
int |
deleteObjectsByProperties(Map<String,Object> properties)
根据属性 批量删除
|
int |
doExecuteNamedSql(String sSql,
Map<String,Object> values)
执行一个带命名参数的sql语句
|
boolean |
doExecuteSql(String sSql) |
int |
doExecuteSql(String sSql,
Object[] values)
直接运行行带参数的 SQL,update delete insert
|
Long |
fetchObjectsCount(Map<String,Object> properties)
根据属性进行并获取总数
|
static String |
fetchSelfOrderSql(String querySql,
Map<String,Object> filterMap)
querySql 用户检查order by 中的字段属性 对应的查询标识 比如,
select a+b as ab from table
在 filterMap 中的 CodeBook.TABLE_SORT_FIELD (sort) 为 ab 字段 返回的排序语句为 a+b
|
static String |
fetchSelfOrderSql(TableInfo ti,
Map<String,Object> filterMap) |
com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(String sSql,
Object[] values,
String[] fieldnames) |
com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(String sSql,
Object[] values,
String[] fieldnames,
int pageNo,
int pageSize) |
static com.alibaba.fastjson.JSONArray |
findObjectsByNamedSql(Connection conn,
String sSql,
Map<String,Object> values,
TableField[] fields) |
List<Object[]> |
findObjectsByNamedSql(String sSql,
Map<String,Object> values) |
List<Object[]> |
findObjectsByNamedSql(String sSql,
Map<String,Object> values,
int pageNo,
int pageSize) |
com.alibaba.fastjson.JSONArray |
findObjectsByNamedSqlAsJSON(String sSql,
Map<String,Object> values,
String[] fieldnames) |
com.alibaba.fastjson.JSONArray |
findObjectsByNamedSqlAsJSON(String sSql,
Map<String,Object> values,
String[] fieldnames,
int pageNo,
int pageSize) |
static com.alibaba.fastjson.JSONArray |
findObjectsBySql(Connection conn,
String sSql,
Object[] params,
TableField[] fields) |
List<Object[]> |
findObjectsBySql(String sSql,
Object[] values)
查询带参数的SQL语句
|
List<Object[]> |
findObjectsBySql(String sSql,
Object[] values,
int pageNo,
int pageSize) |
Connection |
getConnect() |
com.alibaba.fastjson.JSONObject |
getObjectById(Object keyValue)
单主键表
|
com.alibaba.fastjson.JSONObject |
getObjectByProperties(Map<String,Object> properties)
根据属性查询对象
|
Long |
getSimulateSequenceNextValue(String sequenceName)
用表来模拟sequence
create table simulate_sequence (seqname varchar(100) not null primary key,
currvalue integer, increment integer);
|
TableInfo |
getTableInfo() |
int |
insertObjectsAsTabulation(List<Map<String,Object>> objects)
批量添加多条记录
|
com.alibaba.fastjson.JSONArray |
listObjectsByProperties(Map<String,Object> properties)
查询语句默认 不包括 lazy 字段
|
com.alibaba.fastjson.JSONArray |
listObjectsByProperties(Map<String,Object> properties,
int startPos,
int maxSize)
根据属性进行查询
|
Map<String,Object> |
makePkFieldMap(Object keyValue) |
static String |
mapFieldToColumnPiece(String querySql,
String fieldName)
在sql语句中找到属性对应的字段语句
|
Map<String,Object> |
mapObjectProperties(Map<String,Object> properties) |
static Map<String,Object> |
mapObjectProperties(TableInfo tableInfo,
Map<String,Object> properties) |
int |
mergeObject(Collection<String> fields,
Map<String,Object> object)
更改部分属性
|
int |
mergeObject(Map<String,Object> object)
合并
|
int |
replaceObjectsAsTabulation(List<Map<String,Object>> newObjects,
List<Map<String,Object>> dbObjects)
用新的列表覆盖数据库中的列表
|
int |
replaceObjectsAsTabulation(List<Map<String,Object>> newObjects,
Map<String,Object> properties)
用新的列表覆盖数据库中的内容,通过复合外键查询列表
|
int |
replaceObjectsAsTabulation(List<Map<String,Object>> newObjects,
String propertyName,
Object propertyValue)
用新的列表覆盖数据库中的内容,通过单外键查询列表
|
int |
saveNewObject(Map<String,Object> object) |
void |
setConnect(Connection conn) |
void |
setTableInfo(TableInfo tableInfo) |
int |
updateObject(Collection<String> fields,
Map<String,Object> object)
更改部分属性
|
int |
updateObject(Map<String,Object> object)
更改部分属性
|
int |
updateObjectsByProperties(Collection<String> fields,
Map<String,Object> fieldValues,
Map<String,Object> properties)
根据条件批量更新 对象
|
int |
updateObjectsByProperties(Map<String,Object> fieldValues,
Map<String,Object> properties)
根据条件批量更新 对象
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSequenceNextValuepublic static final String TABLE_SORT_FIELD
public static final String TABLE_SORT_ORDER
protected static final org.slf4j.Logger logger
public static Map<String,Object> mapObjectProperties(TableInfo tableInfo, Map<String,Object> properties)
public static GeneralJsonObjectDao createJsonObjectDao(Connection conn, TableInfo tableInfo) throws SQLException
SQLExceptionpublic static GeneralJsonObjectDao createJsonObjectDao(DBType dbtype, Connection conn) throws SQLException
SQLExceptionpublic static GeneralJsonObjectDao createJsonObjectDao(Connection conn) throws SQLException
SQLExceptionpublic static String buildFieldSql(TableInfo ti, String alias, int builderType)
ti - TableInfoalias - StringbuilderType - 1 非lazy字段 2 lazy字段 3 all所有字段public static String buildPartFieldSql(TableInfo ti, Collection<String> fields, String alias, boolean withPk)
ti - TableInfofields - String 值返回对应的字段alias - Stringpublic static org.apache.commons.lang3.tuple.Pair<String,TableField[]> buildSelectSqlWithFields(TableInfo mapInfo, String alias, boolean excludeLazy, String filterSql, boolean withOrderBy, String orderSql)
mapInfo - TableInfo 表信息alias - String 别名excludeLazy - String 是否剔除Lazy字段filterSql - String 过滤语句withOrderBy - String 是否排序orderSql - String 排序语句public static org.apache.commons.lang3.tuple.Pair<String,TableField[]> buildFieldSqlWithFields(TableInfo mapInfo, String alias, boolean excludeLazy)
public static org.apache.commons.lang3.tuple.Pair<String,TableField[]> buildPartFieldSqlWithFields(TableInfo ti, Collection<String> fields, String alias, boolean withPk)
ti - TableInfofields - String 值返回对应的字段alias - Stringpublic static boolean checkHasAllPkColumns(TableInfo tableInfo, Map<String,Object> properties)
public static String mapFieldToColumnPiece(String querySql, String fieldName)
querySql - sql语句fieldName - 属性public static String fetchSelfOrderSql(String querySql, Map<String,Object> filterMap)
querySql - SQL语句 用来检查字段对应的查询语句 片段filterMap - 查询条件map其中包含排序属性public static String fetchSelfOrderSql(TableInfo ti, Map<String,Object> filterMap)
public static String buildFilterSql(TableInfo ti, String alias, Collection<String> properties)
public static com.alibaba.fastjson.JSONArray findObjectsByNamedSql(Connection conn, String sSql, Map<String,Object> values, TableField[] fields) throws SQLException, IOException
public static com.alibaba.fastjson.JSONArray findObjectsBySql(Connection conn, String sSql, Object[] params, TableField[] fields) throws SQLException, IOException
public static String buildCountSqlByProperties(TableInfo tableInfo, Map<String,Object> properties)
public static String buildInsertSql(TableInfo ti, Collection<String> fields)
public static String buildUpdateSql(TableInfo ti, Collection<String> fields)
ti - 表信息fields - 需要更新的字段
param exceptPk 是否可剔除主键public Connection getConnect()
public void setConnect(Connection conn)
public TableInfo getTableInfo()
getTableInfo 在接口中 JsonObjectDaopublic void setTableInfo(TableInfo tableInfo)
public Map<String,Object> makePkFieldMap(Object keyValue) throws SQLException
SQLExceptionpublic com.alibaba.fastjson.JSONObject getObjectById(Object keyValue) throws SQLException, IOException
JsonObjectDaogetObjectById 在接口中 JsonObjectDaokeyValue - keyValueSQLException - SQLExceptionIOException - IOExceptionpublic com.alibaba.fastjson.JSONObject getObjectByProperties(Map<String,Object> properties) throws SQLException, IOException
JsonObjectDaogetObjectByProperties 在接口中 JsonObjectDaoproperties - propertiesSQLException - SQLExceptionIOException - IOExceptionpublic com.alibaba.fastjson.JSONArray listObjectsByProperties(Map<String,Object> properties) throws SQLException, IOException
listObjectsByProperties 在接口中 JsonObjectDaoproperties - 查询字段属性SQLException - SQLExceptionIOException - IOExceptionpublic Long fetchObjectsCount(Map<String,Object> properties) throws SQLException, IOException
JsonObjectDaofetchObjectsCount 在接口中 JsonObjectDaoproperties - propertiesSQLException - SQLExceptionIOException - IOExceptionpublic int saveNewObject(Map<String,Object> object) throws SQLException
saveNewObject 在接口中 JsonObjectDaoSQLExceptionpublic int updateObject(Collection<String> fields, Map<String,Object> object) throws SQLException
updateObject 在接口中 JsonObjectDaofields - 更改部分属性 属性名 集合,应为有的Map 不允许 值为null,这样这些属性 用map就无法修改为 nullobject - MapSQLException - SQLExceptionpublic int updateObject(Map<String,Object> object) throws SQLException
JsonObjectDaoupdateObject 在接口中 JsonObjectDaoobject - objectSQLException - SQLExceptionpublic int mergeObject(Collection<String> fields, Map<String,Object> object) throws SQLException, IOException
JsonObjectDaomergeObject 在接口中 JsonObjectDaofields - 更改部分属性 属性名 集合,应为有的Map 不允许 值为null,这样这些属性 用map就无法修改为 nullobject - objectSQLException - SQLExceptionIOException - IOExceptionpublic int mergeObject(Map<String,Object> object) throws SQLException, IOException
JsonObjectDaomergeObject 在接口中 JsonObjectDaoobject - objectSQLException - SQLExceptionIOException - IOExceptionpublic int updateObjectsByProperties(Collection<String> fields, Map<String,Object> fieldValues, Map<String,Object> properties) throws SQLException
JsonObjectDaoupdateObjectsByProperties 在接口中 JsonObjectDaofields - 更改部分属性 属性名 集合,应为有的Map 不允许 值为null,这样这些属性 用map就无法修改为 nullfieldValues - fieldValuesproperties - propertiesSQLException - SQLExceptionpublic int updateObjectsByProperties(Map<String,Object> fieldValues, Map<String,Object> properties) throws SQLException
JsonObjectDaoupdateObjectsByProperties 在接口中 JsonObjectDaofieldValues - propertiesproperties - propertiesSQLException - SQLExceptionpublic int deleteObjectById(Object keyValue) throws SQLException
JsonObjectDaodeleteObjectById 在接口中 JsonObjectDaokeyValue - keyValueSQLException - SQLExceptionpublic int deleteObjectsByProperties(Map<String,Object> properties) throws SQLException
JsonObjectDaodeleteObjectsByProperties 在接口中 JsonObjectDaoproperties - propertiesSQLException - SQLExceptionpublic int insertObjectsAsTabulation(List<Map<String,Object>> objects) throws SQLException
JsonObjectDaoinsertObjectsAsTabulation 在接口中 JsonObjectDaoobjects - JSONArraySQLException - SQLExceptionpublic int deleteObjects(List<Object> objects) throws SQLException
JsonObjectDaodeleteObjects 在接口中 JsonObjectDaoobjects - JSONArraySQLException - SQLExceptionpublic int deleteObjectsAsTabulation(String propertyName, Object propertyValue) throws SQLException
JsonObjectDaodeleteObjectsAsTabulation 在接口中 JsonObjectDaopropertyName - StringpropertyValue - ObjectSQLException - SQLExceptionpublic int deleteObjectsAsTabulation(Map<String,Object> properties) throws SQLException
JsonObjectDaodeleteObjectsAsTabulation 在接口中 JsonObjectDaoproperties - ObjectSQLException - SQLExceptionpublic static boolean checkNeedUpdate(Map<String,Object> oldObject, Map<String,Object> newObject)
oldObject - 就对象,一般指数据库中的对象newObject - 新对象,一般指待更新的对象public int replaceObjectsAsTabulation(List<Map<String,Object>> newObjects, List<Map<String,Object>> dbObjects) throws SQLException
JsonObjectDaoreplaceObjectsAsTabulation 在接口中 JsonObjectDaonewObjects - JSONArraydbObjects - JSONArraySQLException - SQLExceptionpublic int replaceObjectsAsTabulation(List<Map<String,Object>> newObjects, String propertyName, Object propertyValue) throws SQLException, IOException
JsonObjectDaoreplaceObjectsAsTabulation 在接口中 JsonObjectDaonewObjects - JSONArraypropertyName - StringpropertyValue - ObjectSQLException - SQLExceptionIOException - IOExceptionpublic int replaceObjectsAsTabulation(List<Map<String,Object>> newObjects, Map<String,Object> properties) throws SQLException, IOException
JsonObjectDaoreplaceObjectsAsTabulation 在接口中 JsonObjectDaonewObjects - newObjectsproperties - propertiesSQLException - SQLExceptionIOException - IOExceptionpublic Long getSimulateSequenceNextValue(String sequenceName) throws SQLException, IOException
sequenceName - sequenceNameSQLException - SQLExceptionIOException - IOExceptionpublic List<Object[]> findObjectsBySql(String sSql, Object[] values) throws SQLException, IOException
JsonObjectDaofindObjectsBySql 在接口中 JsonObjectDaosSql - String sql语句values - Object [] 参数SQLException - SQLExceptionIOException - IOExceptionpublic List<Object[]> findObjectsByNamedSql(String sSql, Map<String,Object> values) throws SQLException, IOException
findObjectsByNamedSql 在接口中 JsonObjectDaoSQLExceptionIOExceptionpublic com.alibaba.fastjson.JSONArray findObjectsAsJSON(String sSql, Object[] values, String[] fieldnames) throws SQLException, IOException
findObjectsAsJSON 在接口中 JsonObjectDaoSQLExceptionIOExceptionpublic com.alibaba.fastjson.JSONArray findObjectsByNamedSqlAsJSON(String sSql, Map<String,Object> values, String[] fieldnames) throws SQLException, IOException
findObjectsByNamedSqlAsJSON 在接口中 JsonObjectDaoSQLExceptionIOExceptionpublic boolean doExecuteSql(String sSql) throws SQLException
doExecuteSql 在接口中 JsonObjectDaoSQLExceptionpublic int doExecuteSql(String sSql, Object[] values) throws SQLException
doExecuteSql 在接口中 JsonObjectDaosSql - Stringvalues - Object[]SQLException - SQLExceptionpublic int doExecuteNamedSql(String sSql, Map<String,Object> values) throws SQLException
doExecuteNamedSql 在接口中 JsonObjectDaosSql - Stringvalues - valuesSQLException - SQLExceptionpublic com.alibaba.fastjson.JSONArray listObjectsByProperties(Map<String,Object> properties, int startPos, int maxSize) throws SQLException, IOException
JsonObjectDaolistObjectsByProperties 在接口中 JsonObjectDaoproperties - propertiesstartPos - startPosmaxSize - maxSizeSQLException - SQLExceptionIOException - IOExceptionpublic List<Object[]> findObjectsBySql(String sSql, Object[] values, int pageNo, int pageSize) throws SQLException, IOException
findObjectsBySql 在接口中 JsonObjectDaosSql - String sql语句values - Object [] 参数pageNo - 当前页码pageSize - 每页大小SQLException - SQLExceptionIOException - IOExceptionpublic List<Object[]> findObjectsByNamedSql(String sSql, Map<String,Object> values, int pageNo, int pageSize) throws SQLException, IOException
findObjectsByNamedSql 在接口中 JsonObjectDaoSQLExceptionIOExceptionpublic com.alibaba.fastjson.JSONArray findObjectsAsJSON(String sSql, Object[] values, String[] fieldnames, int pageNo, int pageSize) throws SQLException, IOException
findObjectsAsJSON 在接口中 JsonObjectDaoSQLExceptionIOExceptionpublic com.alibaba.fastjson.JSONArray findObjectsByNamedSqlAsJSON(String sSql, Map<String,Object> values, String[] fieldnames, int pageNo, int pageSize) throws SQLException, IOException
findObjectsByNamedSqlAsJSON 在接口中 JsonObjectDaoSQLExceptionIOExceptionCopyright © 2020 江苏南大先腾信息产业股份有限公司. All rights reserved.