类 UpdateWrapper
- 所有已实现的接口:
Serializable,Cloneable,Map<String,Object>
更新包装对象,例1 :
UpdateWrapper update = mapperManage.createUpdate("update t_user set password=#{p} where id=#{id}");
update.addParam("p", System.currentTimeMillis()).addParam("id", 1);
int execute = update.execute();
log.info("受影响行数: {}", execute);
例2:
UpdateWrapper update = mapperManage.createUpdate("insert into t_user(id,username) values (2,#{un})");
update.addParam("un", "lk");
int execute = update.execute();
log.info("受影响行数: {}", execute);
- 作者:
- lingkang
- 另请参阅:
-
嵌套类概要
从类继承的嵌套类/接口 java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
构造器概要
构造器 -
方法概要
从类继承的方法 java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values从类继承的方法 java.util.AbstractMap
equals, hashCode, toString
-
构造器详细资料
-
UpdateWrapper
-
-
方法详细资料
-
addParam
添加参数,sql中的参数只能用 #{paramName}
代码例子:UpdateWrapper update = mapperManage.createUpdate("update t_user set password=#{p} where id=#{id}"); update.addParam("p", System.currentTimeMillis()).addParam("id", 1); int execute = update.execute(); log.info("受影响行数: {}", execute);- 参数:
name- 参数名value- 参数值- 返回:
- 查询包装对象
-
addParam
添加 map 参数Map<String, Object> map = new HashMap<>(); map.put("id", 123); int execute = mapperManage.createUpdate("insert into t_user(id) values(#{id});") .addParam(map) .execute(); System.out.println(execute); UserMapper mapper = mapperManage.getMapper(UserMapper.class); System.out.println(mapper.selectColumn(new QueryColumn(String.class, "id"))); -
execute
public int execute()执行更新操作- 返回:
- 受影响行数
-