@Component public class JdbcHelper extends Object
| 限定符和类型 | 类和说明 |
|---|---|
class |
JdbcHelper.Table |
| 构造器和说明 |
|---|
JdbcHelper(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
org.mybatis.spring.SqlSessionTemplate sqlSessionTemplate)
JdbcHelper构造函数,初始化数据库操作相关组件
|
| 限定符和类型 | 方法和说明 |
|---|---|
int[] |
batchDelete(String sql,
List params)
批量删除多条记录,针对JdbcTemplate
|
int[] |
batchDelete(String sql,
Object[] params)
批量删除多条记录,针对JdbcTemplate
|
int[] |
batchDeleteByMap(String sql,
List<Map> params)
批量删除多条记录,针对sqlSessionTemplate执行批量删除操作
|
int[] |
batchUpdate(String sql,
List<Object> params)
批量更新数据
|
int[] |
batchUpdate(String sql,
Object[] params)
批量更新数据
|
int[] |
batchUpdateByMap(String sql,
List<Map> params)
批量执行JDBC更新操作,针对jdbcTemplate实现
|
JdbcHelper |
cache(String cacheName,
long ttl)
使用缓存配置JDBC操作
当缓存名为null时直接返回当前对象,否则设置缓存名称和过期时间。
|
void |
clearTableCache()
清空数据库表字段缓存
|
int |
delete(String sql,
List<Object> params)
删除记录
|
int |
delete(String sql,
Map<String,Object> paramMap)
删除数据
|
int |
delete(String sql,
Object[] params)
删除指定记录
|
JdbcHelper |
deleteCache()
删除SQL缓存
如果当前JdbcHelper实例中设置了缓存名称(cacheName),则删除对应的SQL缓存。
|
JdbcHelper |
deleteCache(String name)
删除SQL缓存
|
void |
execute(String sql)
执行脚本语句,没有返回值
|
String |
getCacheName()
获取缓存Key
|
String |
getDatabaseName()
获取默认数据库名称
|
String |
getDatabaseType()
获取默认数据库类型
|
double |
getDouble(String sql,
List<Object> params)
获取Double类型数据
|
double |
getDouble(String sql,
Map<String,Object> paramMap)
获取double类型数据
|
double |
getDouble(String sql,
Object[] params)
获取Double类型数据
|
int |
getInt(String sql,
List<Map<String,Object>> params)
获取Integer类型数据
|
int |
getInt(String sql,
Map<String,Object> paramMap)
根据SQL查询语句和参数Map获取int类型结果
|
int |
getInt(String sql,
Object[] params)
获取Integer类型数据
|
String |
getKey(String key)
获取数据源名称
|
long |
getLong(String sql,
List<Object> params)
获取Long类型数据
|
long |
getLong(String sql,
Map<String,Object> paramMap)
获取Long类型数据
|
long |
getLong(String sql,
Object[] params)
获取Long类型数据
|
Object |
getObject(String sql,
List<Object> params)
获取Object对象
|
Object |
getObject(String sql,
Map<String,Object> paramMap)
获取Object对象
|
Object |
getObject(String sql,
Object[] params)
获取单个Object类型数据
|
String |
getString(String sql,
List<Object> params)
获取字符串数据
|
String |
getString(String sql,
Map<String,Object> paramMap)
获取String类型的数据
|
String |
getString(String sql,
Object[] params)
获取字符串数据
|
Map<String,String> |
getTableComment()
获取默认数据源表备注
|
String |
getTableComment(String tableName)
根据数据源获取表注释
|
Map<String,Map<String,Map<String,Object>>> |
getTableField()
获取默认数据表字段
|
Map<String,Map<String,Object>> |
getTableField(String tableName)
获取默认数据表字段
|
List |
getValues(String sql,
List<Object> params)
获取数据列,例如:[1,3,4,5]
|
List |
getValues(String sql,
Map params)
获取数据列,例如:[1,3,4,5]
|
List |
getValues(String sql,
Object[] params)
获取数据列
|
int |
insert(String sql,
List<Object> params)
插入数据,针对 jdbcTemplate
|
int |
insert(String sql,
Map<String,Object> paramMap)
插入数据
|
int |
insert(String sql,
Object[] params)
插入数据,针对jdbcTemplate
|
static JdbcHelper |
instance()
获取JdbcHelper实例
|
void |
removeTableCache(String key)
根据数据源刷新缓存
|
void |
setCacheName(String cacheName)
设置缓存名
|
void |
setKey(String key)
设置数据源名称
|
JdbcHelper.Table |
table(String tableName)
使用表
|
List<Map<String,Object>> |
toList(String sql)
列表查询,执行指定的SQL查询语句并返回结果列表
示例:select * from table where field1=#{field1} and field2=#{field2}
|
List<Map<String,Object>> |
toList(String sql,
List<Object> params)
列表查询
|
List<Map<String,Object>> |
toList(String sql,
Map<String,Object> paramMap)
获取列表数据
|
List<Map<String,Object>> |
toList(String sql,
Object[] params)
获取数据表
|
Map<String,Object> |
toMap(String sql)
获取Map
根据传入的SQL查询语句执行查询,并返回第一条记录的Map表示
如果查询结果为空则返回null
|
Map<String,Object> |
toMap(String sql,
List<Object> params)
获取单条Map数据
|
Map<String,Object> |
toMap(String sql,
Map<String,Object> paramMap)
根据SQL查询语句和参数获取Map结果
|
Map<String,Object> |
toMap(String sql,
Object[] params)
获取单条Map数据
|
Pager<Map<String,Object>> |
toPager(String sql)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
List<Object> params)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
List<Object> params,
javax.servlet.http.HttpServletRequest request)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
List<Object> params,
int offset,
int limit)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
Map<String,Object> paramMap)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
Map<String,Object> paramMap,
javax.servlet.http.HttpServletRequest request)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
Map<String,Object> paramMap,
int offset,
int limit)
手工分页
|
Pager<Map<String,Object>> |
toPager(String sql,
Object[] params)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
Object[] params,
javax.servlet.http.HttpServletRequest request)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
Object[] params,
int offset,
int limit)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
String countSQL,
List<Object> params,
javax.servlet.http.HttpServletRequest request)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
String countSQL,
List<Object> params,
int offset,
int limit)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
String countSQL,
Map<String,Object> paramMap,
int offset,
int limit)
手工分页查询方法
|
Pager<Map<String,Object>> |
toPager(String sql,
String countSQL,
Object[] params,
javax.servlet.http.HttpServletRequest request)
分页查询
|
Pager<Map<String,Object>> |
toPager(String sql,
String countSQL,
Object[] params,
int offset,
int limit)
分页查询数据
|
org.ssssssss.magicapi.modules.db.Transaction |
transaction()
开启事务,手动提交和回滚
|
Object |
transaction(Function<?,?> function)
开启事务,在一个回调中进行操作
|
int |
update(String sql,
List<Object> params)
更新指定记录
|
int |
update(String sql,
Map<String,Object> paramMap)
更新数据
|
int |
update(String sql,
Object[] params)
更新指定记录
|
JdbcHelper |
use(String key)
切换数据源进行SQL接口操作
|
public JdbcHelper(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
org.mybatis.spring.SqlSessionTemplate sqlSessionTemplate)
jdbcTemplate - JDBC操作模板,用于执行SQL语句sqlSessionTemplate - MyBatis SQL会话模板,用于执行MyBatis映射语句
初始化内容:
1. 从Spring容器获取动态数据源实例
2. 保存传入的JDBC模板和SQL会话模板@Comment(value="\u83b7\u53d6\u7f13\u5b58Key") public String getCacheName()
public void setCacheName(@Comment(name="cacheName",value="\u7f13\u5b58\u540d")
String cacheName)
cacheName - 缓存名@Comment(value="\u4f7f\u7528\u7f13\u5b58") public JdbcHelper cache(@Comment(name="cacheName",value="\u7f13\u5b58\u540d") String cacheName, @Comment(name="ttl",value="\u8fc7\u671f\u65f6\u95f4") long ttl)
cacheName - 缓存名称,用于标识缓存实例ttl - 缓存条目过期时间(毫秒),-1表示永不过期@Comment(value="\u83b7\u53d6JdbcHelper\u5b9e\u4f8b") public static JdbcHelper instance()
@Comment(value="\u8bbe\u7f6e\u6570\u636e\u6e90\u540d\u79f0") public void setKey(String key)
key - 数据源名称@Comment(value="\u83b7\u53d6\u6570\u636e\u6e90\u540d\u79f0") public String getKey(String key)
key - 参数说明(当前函数实现中未使用该参数,可能是设计遗留问题)@Comment(value="\u6e05\u7a7a\u6570\u636e\u5e93\u8868\u5b57\u6bb5\u7f13\u5b58")
public void clearTableCache()
throws SQLException
SQLException@Comment(value="\u6839\u636e\u6570\u636e\u6e90\u5237\u65b0\u7f13\u5b58")
public void removeTableCache(@Comment(value="\u6570\u636e\u6e90\u540d\u79f0")
String key)
throws SQLException
key - 数据源名称SQLException@Comment(value="\u83b7\u53d6\u9ed8\u8ba4\u6570\u636e\u5e93\u540d\u79f0") public String getDatabaseName() throws SQLException
SQLException@Comment(value="\u83b7\u53d6\u9ed8\u8ba4\u6570\u636e\u5e93\u7c7b\u578b") public String getDatabaseType() throws SQLException
SQLException - 如果获取数据库类型时发生SQL异常@Comment(value="\u5f00\u542f\u4e8b\u52a1\uff0c\u5e76\u5728\u56de\u8c03\u4e2d\u5904\u7406") public Object transaction(@Comment(name="function",value="\u56de\u8c03\u51fd\u6570\uff0c\u5982\uff1a()=>{....}") Function<?,?> function)
function - 回调函数@Comment(value="\u5f00\u542f\u4e8b\u52a1\uff0c\u624b\u52a8\u63d0\u4ea4\u548c\u56de\u6eda") public org.ssssssss.magicapi.modules.db.Transaction transaction()
@Comment(value="\u6839\u636e\u6570\u636e\u540d\u83b7\u53d6\u8868\u6ce8\u91ca") public String getTableComment(@Comment(value="\u6570\u636e\u6e90\u540d\u79f0") String tableName) throws SQLException
tableName - 数据源SQLException@Comment(value="\u83b7\u53d6\u5f53\u524d\u9ed8\u8ba4\u6570\u636e\u5e93\u8868\u6ce8\u91ca") public Map<String,String> getTableComment() throws SQLException
SQLException@Comment(value="\u6839\u636e\u6570\u636e\u5e93\u540d\u548c\u8868\uff0c\u83b7\u53d6\u8868\u5b57\u6bb5\u6ce8\u91ca") public Map<String,Map<String,Object>> getTableField(@Comment(value="\u8868\u540d") String tableName) throws SQLException
SQLException@Comment(value="\u6839\u636e\u6570\u636e\u5e93\u540d\u548c\u8868\uff0c\u83b7\u53d6\u8868\u5b57\u6bb5\u6ce8\u91ca") public Map<String,Map<String,Map<String,Object>>> getTableField() throws SQLException
SQLException@Comment(value="\u5207\u6362\u6570\u636e\u6e90") public JdbcHelper use(@Comment(value="\u6570\u636e\u6e90") String key) throws SQLException
key - 数据源SQLException@Comment(value="\u4f7f\u7528\u8868") public JdbcHelper.Table table(@Comment(value="\u8868\u540d") String tableName) throws SQLException
tableName - 表名SQLException - 如果发生SQL异常@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5\uff1aselect * from table where id=? and name=?") String sql, @Comment(value="\u4f8b\u5982:[id,name]") List<Object> params, @Comment(value="\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment(value="\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
sql - 查询语句:select * from table where id=? and name=?params - 查询参数列表,例如:[id,name]offset - 从第几行起limit - 一页显示几行@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5\uff1aselect * from table where id=? and name=?") String sql, @Comment(value="\u4f8b\u5982\uff1a[id,name]") Object[] params, @Comment(value="\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment(value="\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
sql - 查询语句:select * from table where id=? and name=?params - 查询参数,例如:[id,name]offset - 从第几行起limit - 一页显示几行@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment(value="\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params, @Comment(value="\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment(value="\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
sql - 查询语句,例如:select * from table where field1=? and field2=?countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?params - 查询参数列表,例如:[参数1,参数2]offset - 从第几行起limit - 一页显示几行@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment(value="\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params, @Comment(value="\u4ece\u7b2c\u51e0\u884c\u8d77") javax.servlet.http.HttpServletRequest request)
sql - 查询语句,例如:select * from table where field1=? and field2=?countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?params - 查询参数列表,例如:[参数1,参数2]request - HttpServletRequest对象,用于获取分页参数(从第几行起)@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment(value="\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params, @Comment(value="\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment(value="\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
sql - 查询语句,例如:select * from table where field1=? and field2=?countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?params - 查询参数数组,例如:[参数1,参数2]offset - 从第几行开始查询(起始行)limit - 每页显示的记录数@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
sql - 查询语句params - 例如:[参数1,参数2]@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment(value="\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params, @Comment(value="HttpServletRequest") javax.servlet.http.HttpServletRequest request)
sql - 查询语句,例如:select * from table where field1=? and field2=?countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?params - 查询参数,例如:[参数1,参数2]request - HttpServletRequest对象,用于获取分页参数@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params, @Comment(value="HttpServletRequest") javax.servlet.http.HttpServletRequest request)
sql - 查询语句,例如:select * from table where field1=? and field2=?params - 查询参数数组,例如:[参数1,参数2]request - HttpServletRequest对象,用于获取分页参数@Comment(value="\u5217\u8868\u67e5\u8be2,\u4f8b\u5982 select * from table where field1=#{field1} and field2=#{field2}")
public List<Map<String,Object>> toList(@Comment(value="\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?")
String sql)
示例:select * from table where field1=#{field1} and field2=#{field2}
sql - 查询语句,示例:select * from table where field1=? and field2=?@Comment(value="\u83b7\u53d6\u6570\u636e\u8868") public List<Map<String,Object>> toList(@Comment(value="\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
sql - 查询语句,例如:select * from table where field1=? and field2=?params - 查询参数数组,例如:[参数1,参数2]@Comment(value="\u5220\u9664`SQL`\u7f13\u5b58") public JdbcHelper deleteCache(@Comment(value="\u7f13\u5b58\u540d\u79f0") String name)
name - 缓存名称,非空时执行删除操作@Comment(value="\u5220\u9664`SQL`\u7f13\u5b58") public JdbcHelper deleteCache()
如果当前JdbcHelper实例中设置了缓存名称(cacheName),则删除对应的SQL缓存。
@Comment(value="\u5217\u8868\u67e5\u8be2") public List<Map<String,Object>> toList(@Comment(value="\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
sql - 查询语句params - 例如:[参数1,参数2]@Comment(value="\u83b7\u53d6\u6570\u636e\u5217") public List getValues(@Comment(value="\u5355\u5217\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982: select id from table where field=? and field1=?") String sql, @Comment(value="\u53c2\u6570:[\u53c2\u65701\uff0c\u53c2\u65702]") Object[] params)
sql - 单列查询语句,例如: select id from table where field=? and field1=?params - 参数:[参数1,参数2]@Comment(value="\u83b7\u53d6\u6570\u636e\u5217\uff0c\u4f8b\u5982\uff1a[1,3,4,5]") public List getValues(@Comment(value="\u5355\u5217\u67e5\u8be2\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aselect id from table where field1=? and field2=?") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
sql - 单列查询语句,例如:select id from table where field1=? and field2=?params - 查询参数列表,例如:[参数1,参数2]@Comment(value="\u83b7\u53d6\u6570\u636e\u5217\uff0c\u4f8b\u5982\uff1a[1,3,4,5]") public List getValues(@Comment(value="\u5355\u5217\u67e5\u8be2\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aselect id from table where name=?") String sql, @Comment(value="\u4f8b\u5982\uff1a{name:\'1\'}") Map params)
sql - 单列查询语句,例如:select id from table where name=?params - 查询参数,例如:{name:'1'}@Comment(value="\u63d2\u5165\u6570\u636e\uff0c\u9488\u5bf9 jdbcTemplate")
public int insert(@Comment(value="\u63d2\u5165\u8bed\u53e5:insert table(field1,field2) values (?,?)")
String sql,
@Comment(value="\u53c2\u6570\uff1a[\u53c2\u65701\uff0c\u53c2\u65702]")
Object[] params)
sql - 插入语句:insert table(field1,field2) values (?,?)params - 参数:[参数1,参数2]@Comment(value="\u63d2\u5165\u6570\u636e\uff0c\u9488\u5bf9 jdbcTemplate")
public int insert(@Comment(value="\u63d2\u5165\u8bed\u53e5:insert table(field1,field2) values (?,?)")
String sql,
@Comment(value="\u53c2\u6570\uff1a[\u53c2\u65701\uff0c\u53c2\u65702]")
List<Object> params)
sql - 插入语句:insert table(field1,field2) values (?,?)params - 参数:[参数1,参数2]@Comment(value="\u6279\u91cf\u64cd\u4f5c,\u9488\u5bf9jdbcTemplate")
public int[] batchUpdateByMap(@Comment(value="\u66f4\u65b0\u8bed\u53e5\uff1aupdate table set name=? where id=?")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[{id\uff1a3,name:\'a\'},{id:4,name:\'b\'}]")
List<Map> params)
sql - 更新SQL语句,使用占位符格式如:'update table set name=? where id=?'params - 参数列表,每个Map对应一条记录的参数,格式如:[{id:'1',name:'aaa'},{id:'2',name:'bbb'}]@Comment(value="\u66f4\u65b0\u6307\u5b9a\u8bb0\u5f55")
public int update(@Comment(value="\u4f8b\u5982\uff1aupdate table set name=? where id=?")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[name,id]")
Object[] params)
sql - SQL更新语句,例如:update table set name=? where id=?params - SQL参数数组,例如:[name,id]@Comment(value="\u66f4\u65b0\u6307\u5b9a\u8bb0\u5f55")
public int update(@Comment(value="\u4f8b\u5982\uff1aupdate table set name=? where id=?")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[name,id]")
List<Object> params)
sql - SQL更新语句,格式例如:update table set name=? where id=?params - 参数列表,例如:[name,id]@Comment(value="\u5220\u9664\u6307\u5b9a\u8bb0\u5f55")
public int delete(@Comment(value="\u4f8b\u5982\uff1adelete from table where id=? and name=?")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[table,id,name]")
Object[] params)
sql - SQL删除语句,例如:delete from table where id=? and name=?params - SQL参数数组,例如:[table,id,name]@Comment(value="\u6279\u91cf\u5220\u9664\u591a\u6761\u8bb0\u5f55,\u9488\u5bf9sqlSessionTemplate")
public int[] batchDeleteByMap(@Comment(value="\u4f8b\u5982\uff1adelete from table where id=#{id} and name=#{name}")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[{id:\'1\',name:\'aa\'},{id:\'2\',name:\'b\'}]")
List<Map> params)
sql - SQL删除语句模板,例如:delete from table where id=#{id} and name=#{name}params - 参数列表,每个Map对应一条记录的删除参数,例如:[{id:'1',name:'aa'},{id:'2',name:'b'}]@Comment(value="\u6279\u91cf\u5220\u9664\u591a\u6761\u8bb0\u5f55\uff0c\u9488\u5bf9JdbcTemplate")
public int[] batchDelete(@Comment(value="\u4f8b\u5982\uff1adelete from table where id=?\' \u6216\u8005 delete from table where id=? and name=?")
String sql,
@Comment(value=" [id,id,id] \u6216\u8005 [[id,name],[id,name], [id,name],[id,name]]")
List params)
sql - SQL删除语句,例如:"delete from table where id=?" 或 "delete from table where id=? and name=?"params - 参数列表,格式为:[id,id,id] 或 [[id,name],[id,name], [id,name],[id,name]]@Comment(value="\u6279\u91cf\u5220\u9664\u591a\u6761\u8bb0\u5f55\uff0c\u9488\u5bf9JdbcTemplate")
public int[] batchDelete(@Comment(value="\u4f8b\u5982\uff1adelete from table where id=?\' \u6216\u8005 delete from table where id=? and name=?")
String sql,
@Comment(value=" [id,id,id] \u6216\u8005 [[id,name],[id,name], [id,name],[id,name]]")
Object[] params)
sql - SQL删除语句,例如:"delete from table where id=?" 或 "delete from table where id=? and name=?"params - 参数数组,可以是单个ID数组[id,id,id]或复合条件数组[[id,name],[id,name]]@Comment(value="\u5220\u9664\u8bb0\u5f55")
public int delete(@Comment(value="\u4f8b\u5982\uff1adelete from table=? where id =? and name=?")
String sql,
@Comment(value="\u53c2\u6570\uff1a[id,name]")
List<Object> params)
sql - SQL语句,例如:delete from table=? where id =? and name=?params - 参数列表,例如:[id,name]@Comment(value="\u6267\u884c\u811a\u672c\u8bed\u53e5\uff0c\u6ca1\u6709\u8fd4\u56de\u503c")
public void execute(@Comment(value="\u811a\u672c\u8bed\u53e5")
String sql)
throws SQLException
sql - 脚本语句,支持用分号分隔的多条SQL语句SQLException - 当执行SQL语句发生错误时抛出@Comment(value="\u83b7\u53d6\u5355\u6761Map\u6570\u636e") public Map<String,Object> toMap(@Comment(value="\u5355\u6761\u6570\u636e\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
sql - 单条数据查询语句params - 查询参数数组,例如:[参数1,参数2]@Comment(value="\u83b7\u53d6\u5355\u6761Map\u6570\u636e") public Map<String,Object> toMap(@Comment(value="\u5355\u6761\u6570\u636e\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
sql - 单条数据查询语句params - 查询参数列表,例如:[参数1,参数2]@Comment(value="\u83b7\u53d6\u5355\u4e2aObject\u7c7b\u578b\u6570\u636e") public Object getObject(@Comment(value="\u5355\u6761\u6570\u636e\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
sql - 单条数据查询语句params - 例如:[参数1,参数2]@Comment(value="\u83b7\u53d6\u5b57\u7b26\u4e32\u6570\u636e") public String getString(@Comment(value="sql\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
sql - sql语句params - 例如:[参数1,参数2]@Comment(value="\u83b7\u53d6\u5b57\u7b26\u4e32\u6570\u636e") public String getString(@Comment(value="sql\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
sql - sql语句params - 参数列表,例如:[参数1,参数2]@Comment(value="\u83b7\u53d6Integer\u7c7b\u578b\u6570\u636e")
public int getInt(@Comment(value="sql\u8bed\u53e5")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]")
Object[] params)
sql - sql语句params - 例如:[参数1,参数2]@Comment(value="\u83b7\u53d6Integer\u7c7b\u578b\u6570\u636e")
public int getInt(@Comment(value="sql\u8bed\u53e5")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]")
List<Map<String,Object>> params)
sql - sql语句params - 参数列表,例如:[参数1,参数2]@Comment(value="\u83b7\u53d6Long\u7c7b\u578b\u6570\u636e")
public long getLong(@Comment(value="sql\u8bed\u53e5")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]")
Object[] params)
sql - sql语句params - 例如:[参数1,参数2]@Comment(value="\u83b7\u53d6Long\u7c7b\u578b\u6570\u636e")
public long getLong(@Comment(value="sql\u8bed\u53e5")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]")
Map<String,Object> paramMap)
sql - sql语句paramMap - 参数映射,例如:[参数1,参数2]@Comment(value="\u83b7\u53d6Long\u7c7b\u578b\u6570\u636e")
public long getLong(@Comment(value="sql\u8bed\u53e5")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]")
List<Object> params)
sql - sql语句params - 参数列表,例如:[参数1,参数2]@Comment(value="\u83b7\u53d6Double\u7c7b\u578b\u6570\u636e")
public double getDouble(@Comment(value="sql\u8bed\u53e5")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]")
Object[] params)
sql - sql语句params - 例如:[参数1,参数2]@Comment(value="\u83b7\u53d6Double\u7c7b\u578b\u6570\u636e")
public double getDouble(@Comment(value="sql\u8bed\u53e5")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]")
List<Object> params)
sql - sql语句params - 参数列表,例如:[参数1,参数2]@Comment(value="\u624b\u5de5\u5206\u9875") public Pager<Map<String,Object>> toPager(@Comment(value="sql\u8bed\u53e5") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Map<String,Object> paramMap, @Comment(value="\u4ece\u7b2c\u51e0\u884c\u8d77\u59cb") int offset, @Comment(value="\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
sql - sql语句paramMap - 参数映射,例如:[参数1,参数2]offset - 从第几行起始limit - 一页显示几行@Comment(value="\u624b\u5de5\u5206\u9875") public Pager<Map<String,Object>> toPager(@Comment(value="sql\u8bed\u53e5") String sql, @Comment(value="\u7edf\u8ba1sql\u8bed\u53e5") String countSQL, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Map<String,Object> paramMap, @Comment(value="\u4ece\u7b2c\u51e0\u884c\u8d77\u59cb") int offset, @Comment(value="\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
sql - 查询数据的SQL语句countSQL - 统计总数的SQL语句paramMap - 查询参数Map,例如:[参数1,参数2]offset - 从第几行开始查询(从0开始计数)limit - 每页显示的数据行数@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u4f8b\u5982\uff1aselect * from table") String sql)
sql - SQL查询语句,例如:select * from table@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u4f8b\u5982\uff1aselect * from table") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Map<String,Object> paramMap)
sql - SQL查询语句,例如:select * from tableparamMap - 查询参数映射,例如:[参数1,参数2]@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u4f8b\u5982\uff1aselect * from table") String sql, @Comment(value="\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
sql - SQL查询语句,例如:select * from tableparams - 查询参数列表,例如:[参数1,参数2]@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u4f8b\u5982\uff1aselect * from table") String sql, @Comment(value="\u53c2\u6570") List<Object> params, @Comment(value="HttpServletRequest") javax.servlet.http.HttpServletRequest request)
sql - 例如:select * from tableparams - 参数列表request - HttpServletRequest对象@Comment(value="\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment(value="\u4f8b\u5982\uff1aselect * from table") String sql, @Comment(value="\u4f8b\u5982\uff1a{name:\'a\'}") Map<String,Object> paramMap, @Comment(value="HttpServletRequest") javax.servlet.http.HttpServletRequest request)
sql - SQL查询语句,例如:select * from tableparamMap - 查询参数Map,例如:{name:'a'}request - HttpServletRequest对象,用于获取分页参数@Comment(value="\u83b7\u53d6\u5217\u8868") public List<Map<String,Object>> toList(@Comment(value="\u4f8b\u5982\uff1aselect * from table") String sql, @Comment(value="\u4f8b\u5982\uff1a{name:\'a\'}") Map<String,Object> paramMap)
sql - SQL查询语句,例如:select * from tableparamMap - 查询参数Map,例如:{name:'a'}@Comment(value="\u63d2\u5165\u6570\u636e")
public int insert(@Comment(value="\u4f8b\u5982\uff1ainsert into table(name) values(#{name})")
String sql,
@Comment(value="\u4f8b\u5982\uff1a{name:\'a\'}")
Map<String,Object> paramMap)
sql - SQL插入语句,例如:insert into table(name) values(#{name})paramMap - 参数映射Map,例如:{name:'a'}@Comment(value="\u66f4\u65b0\u6570\u636e")
public int update(@Comment(value="\u4f8b\u5982\uff1aupdate table set name=#{name} where id=#{id}")
String sql,
@Comment(value="\u4f8b\u5982\uff1a{id:1,name:\'a\'}")
Map<String,Object> paramMap)
sql - SQL更新语句,例如:update table set name=#{name} where id=#{id}paramMap - 参数映射Map,例如:{id:1,name:'a'}@Comment(value="\u6279\u91cf\u66f4\u65b0\u6570\u636e")
public int[] batchUpdate(@Comment(value="\u4f8b\u5982\uff1aupdate table set name=1 where id=? \u6216\u8005 update table set name=? where id=?")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[id,id,id,id] \u6216\u8005[[name,id],[name,id],[\'name\',\'id\']]")
Object[] params)
sql - SQL更新语句,例如:update table set name=1 where id=? 或者 update table set name=? where id=?params - 参数数组,可以是单个值数组[id,id,id,id],也可以是二维数组[[name,id],[name,id],['name','id']]@Comment(value="\u6279\u91cf\u66f4\u65b0\u6570\u636e")
public int[] batchUpdate(@Comment(value="\u4f8b\u5982\uff1aupdate table name=22 where id=? \u6216\u8005 update table name=? where id=?")
String sql,
@Comment(value="\u4f8b\u5982\uff1a[id,id,id,id] \u6216\u8005[[name,id],[name,id]]")
List<Object> params)
sql - SQL更新语句,例如:update table name=22 where id=? 或者 update table name=? where id=?params - 参数列表,例如:[id,id,id,id] 或者 [[name,id],[name,id]]@Comment(value="\u5220\u9664\u6570\u636e")
public int delete(@Comment(value="\u4f8b\u5982\uff1adelete from table where id=#{id}")
String sql,
@Comment(value="\u4f8b\u5982\uff1a{id:1}")
Map<String,Object> paramMap)
sql - SQL删除语句,例如:delete from table where id=#{id}paramMap - 参数映射Map,例如:{id:1}@Comment(value="\u83b7\u53d6Map") public Map<String,Object> toMap(@Comment(value="\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u53c2\u6570") Map<String,Object> paramMap)
sql - 查询语句paramMap - 参数Map@Comment(value="\u83b7\u53d6Map") public Map<String,Object> toMap(@Comment(value="\u67e5\u8be2\u8bed\u53e5") String sql)
sql - 查询语句@Comment(value="\u83b7\u53d6Object") public Object getObject(@Comment(value="\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u53c2\u6570") Map<String,Object> paramMap)
sql - 查询语句paramMap - 参数映射Map@Comment(value="\u83b7\u53d6Object") public Object getObject(@Comment(value="\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u53c2\u6570") List<Object> params)
sql - 查询语句params - 参数列表@Comment(value="\u83b7\u53d6String") public String getString(@Comment(value="\u67e5\u8be2\u8bed\u53e5") String sql, @Comment(value="\u53c2\u6570") Map<String,Object> paramMap)
sql - 查询语句paramMap - 参数映射Map@Comment(value="\u83b7\u53d6int")
public int getInt(@Comment(value="\u67e5\u8be2\u8bed\u53e5")
String sql,
@Comment(value="\u53c2\u6570")
Map<String,Object> paramMap)
sql - 查询语句paramMap - 参数Map,键为参数名,值为参数值Copyright © 2025. All rights reserved.