数据库相关操作的基类
成员函数:
ExecHash
执行传入的sql语句,并返回hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
ZmHash hash结构
ExecHashList
执行传入的sql语句,并返回HashList结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
ZmHashList HashList结构
ExecHsHash
执行传入的sql语句,并返回hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
ZmHash hash结构
ExecHashEntity
执行传入的sql语句,并返回hash结构,字段为实体名称的形式
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
ZmHash hash结构 字段为实体名称
ExecHsHashList
执行传入的sql语句,并返回HashList结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
ZmHashList HashList结构
ExecHashEntityList
执行传入的sql语句,并返回HashList结构,字段为实体名称的形式
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
ZmHashList HashList结构,字段为实体名称的形式
InsertIdentity
插入含有自增列主键的表,并返回该表整型自增列主键值
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
Int 整型主键值
InsertLongIdentity
插入含有自增列主键的表,并返回该表长整型自增列主键值
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| sql| String | sql语句 |
返回值:
Int 长整型主键值
ExecNonQuery
直接操作数据库
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| commandText| String | sql语句 |
返回值:
Int 影响记录条数
SearchList
根据相应的表数据,条件数据,分页数据,排序数据查询数据库,获得ZmHashList对象
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| mainTable| ZmQueryTable | 表数据 |
| subTables| ZmQueryTableList | 关联表数据 |
| queryCondition| ZmQueryConditionList | 查询条件 |
| Pager| ZmPager | 分页数据 |
| Sorter| ZmSorter | 排序数据 |
返回值:
ZmHashList 查询出的内容,ZmHashList对象
SearchEntityList
根据相应的表数据,条件数据,分页数据,排序数据查询数据库,获得ZmHashList对象,对象中的key转化为实体的形式
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| mainTable| ZmQueryTable | 表数据 |
| subTables| ZmQueryTableList | 关联表数据 |
| queryCondition| ZmQueryConditionList | 查询条件 |
| Pager| ZmPager | 分页数据 |
| Sorter| ZmSorter | 排序数据 |
返回值:
ZmHashList 查询出的内容,ZmHashList对象,对象中的key转化为实体的形式
SqlConcat
sql里的字符串连接函数,翻译字符串连接函数 适配多种数据库
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| fields| 多个String可变参数 | 多个需要连接的项 可变参数 |
返回值:
String 连接后的字符串sql语句
SqlIsNull
sql里的字符串判空函数,翻译字符串判空函数 适配多种数据库
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| field| String | 字段 |
| nullValue| String | 如果字段为空后的值 |
返回值:
String 判空后字符串sql语句
SelectHash
根据传入参数生成并执行sql语句,并返回hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHash hash结构
SelectTopHash
根据传入参数生成并执行sql语句取出前多少条数据,并返回hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| top| Int | 查询前多少条数据 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHash hash结构
SelectHashWhere
根据传入表数据和where条件生成并执行sql语句,并返回hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHash hash结构
SelectHashEntity
根据传入参数生成并执行sql语句,并返回字段为实体方式的hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHash 字段为实体方式的hash结构
SelectTopHashEntity
根据传入参数生成并执行sql语句取出前多少条数据,并返回字段为实体方式的hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| top| Int | 查询前多少条数据 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHash 字段为实体方式的hash结构
SelectHashEntityWhere
根据传入表数据和where条件生成并执行sql语句,并返回字段为实体方式的hash结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHash 字段为实体方式的hash结构
SelectHashList
根据传入参数生成并执行sql语句,并返回hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList hashlist结构
SelectTopHashList
根据传入参数生成并执行sql语句取出前多少条数据,并返回hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| top| Int | 查询前多少条数据 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList hashlist结构
SelectHashListWhere
根据传入表数据和where条件生成并执行sql语句,并返回hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList hashlist结构
SelectHashEntityList
根据传入参数生成并执行sql语句,并返回字段为实体方式的hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList 字段为实体方式的hashlist结构
SelectTopHashEntityList
根据传入参数生成并执行sql语句取出前多少条数据,并返回字段为实体方式的hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| top| Int | 查询前多少条数据 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList 字段为实体方式的hashlist结构
SelectHashEntityListWhere
根据传入表数据和where条件生成并执行sql语句,并返回字段为实体方式的hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList 字段为实体方式的hashlist结构
SqlSelectWhere
根据传入参数生成sql语句,根据查询表,where条件和查询列
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
String 生成后的sql语句
SqlSelect
根据传入参数生成sql语句
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
String 生成后的sql语句
SqlSelectTop
根据传入参数生成sql语句 top选择多少条数据
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| top| Int | 查询前多少条数据 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
String 生成后的sql语句
SqlCastVarchar
sql里的类型转化为字符串函数,翻译字符串判空函数 适配多种数据库
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| field| String | 字段 |
| len| Int | 转为字符串类型的长度 |
返回值:
String 转化后字符串sql语句
SqlCaseWhen
sql里的casewhen函数,翻译字符串连接函数 适配多种数据库
case image_flag when 1 then image_file when 2 then '/test.jpg' else '/jsp.jpg' end =>SqlCaseWhen(image_flag,"'/jsp.jpg'",1,image_file,2,"'/test.jpg'")
case when image_flag=1 then image_file else '/jsp.jpg' end =>SqlCaseWhen("","'/jsp.jpg'","image_flag=1",image_file)
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| caseItem| String | case 后面的项 可以不传 不传后面when为条件表达式 参考sql语法 |
| elseResult| String | else 后面的 |
| whenAndThens| String可变参数 | when then 对,可变参数 可以有多个when和then |
返回值:
String case when后的字符串sql语句
SelectPageNoSizeHashList
根据传入参数页码及查询条数生成并执行sql语句取出数据,并返回hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| pageno| Int | 页码 |
| size| Int | 当前查询条数 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList hashlist结构
SelectStartLimitHashList
根据传入开始位置及查询条数生成并执行sql语句取出数据,并返回hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| start| Int | 开始位置 |
| count| Int | 当前查询条数 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList hashlist结构
SelectPageNoSizeHashEntityList
根据传入参数页码及查询条数生成并执行sql语句取出数据,并返回实体形式字段的hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| pageno| Int | 页码 |
| size| Int | 当前查询条数 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList 实体形式字段的hashlist结构
SelectStartLimitHashEntityList
根据传入开始位置及查询条数生成并执行sql语句取出数据,并返回实体形式字段的hashlist结构
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| start| Int | 开始位置 |
| count| Int | 当前查询条数 |
| Tables| String | 查询表 |
| wheres| String | where条件 |
| orderbys| String | 排序 |
| fields| String | 查询列 可变参数可以传入多个 |
返回值:
ZmHashHashList 实体形式字段的hashlist结构
SelectCount
根据传入的查询表和where条件生成并执行sql语句,查询数据的条数
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Tables| String | 查询表 |
| wheres| String | where条件 |
返回值:
Int 查询数据的条数
InsertByParamToKeyValues
根据hash数据和参数列表插入数据
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 插入的表名 |
| sqlkeyvalues| ZmStr2StrHash | hash数据 |
| paramlist| ZmSqlParamList | 参数列表 |
UpdateByParamsAndKey
根据参数列表更新数据
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| paramlist| ZmSqlParamList | 普通参数 |
| keylist| ZmSqlParamList | where后的参数 |
UpdateByConditions
根据参数列表更新符合条件列表的数据
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| paramlist| ZmSqlParamList | 参数列表 |
| queryCondition| ZmQueryConditionList | 查询条件列表 |
Delete
删除符合条件列表的数据
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| queryCondition| ZmQueryConditionList | 条件列表 |
QuoteName
对有些数据库的关键子字段加相关符号,区分是字段还是数据库关键字 如mysql加` sqlserver加[]等
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Name| String | 传入名称 |
返回值:
String 加完符号的名称
ToEntityName
数据库名称转换为实体名称 下滑线名称转化为CamelCase
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Name| String | 传入名称 |
返回值:
String 转换后的名称
ToDbName
实体名称转换为数据库名称 CamelCase转化为下滑线名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| Name| String | 传入名称 |
返回值:
String 转换后的名称
HashToEntityName
对hash表的每个字段,数据库名称转换为实体名称 下滑线名称转化为CamelCase
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| hash| ZmHash | 传入名称 |
HashListToEntityName
对hashlist的每个字段,数据库名称转换为实体名称 下滑线名称转化为CamelCase
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| hashlist| ZmHashList | 传入名称 |
HashToDbName
对hash表的每个字段,实体名称转换为数据库名称 CamelCase转化为下滑线名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| hash| ZmHash | 传入名称 |
HashListToDbName
对hashlist的每个字段,实体名称转换为数据库名称 CamelCase转化为下滑线名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| hashlist| ZmHashList | 传入名称 |
InsertByParamListCore
根据sql参数列表插入数据,sql参数名称就是列(col)名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| paramlist| ZmSqlParamList | 参数列表 |
| hasIdentity| Boolean | 是否存在和返回自增列 |
返回值:
Serializable 如果参数中存在自增列 那么返回的是自增列的id 否则返回受影响的条数
InsertIdentityByParamList
根据sql参数列表插入数据并返回自增列id,sql参数名称就是列(col)名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| paramlist| ZmSqlParamList | 参数列表 |
返回值:
Serializable 返回的是自增列的id
InsertByParamList
根据sql参数列表插入数据,sql参数名称就是列(col)名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| paramlist| ZmSqlParamList | 参数列表 |
返回值:
Serializable 返回受影响的条数
InsertLongIdentityByParamList
根据sql参数列表插入数据并返回自增列id长整型,sql参数名称就是列(col)名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| paramlist| ZmSqlParamList | 参数列表 |
返回值:
long 返回的是自增列的id长整型
InsertIntIdentityByParamList
根据sql参数列表插入数据并返回自增列id整型,sql参数名称就是列(col)名称
参数:
| 名称 | 类型 | 说明 |
| -------- | -----: | :----: |
| tableName| String | 表名 |
| paramlist| ZmSqlParamList | 参数列表 |
返回值:
int 返回的是自增列的id整型
其它说明:
无