mabatisplus-update

 

 

/**
* <p>
* 根据 whereEntity 条件,更新记录
* </p>
*
* @param entity 实体对象 (set 条件值,不能为 null)
* @param updateWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句)
*/
@Test
public void update() {

//修改值
User user = new User();
user.setStatus(true);
user.setName("zhangsan");

//修改条件s
UpdateWrapper<User> userUpdateWrapper = new UpdateWrapper<>();
userUpdateWrapper.eq("name", "lqf");

int update = mapper.update(user, userUpdateWrapper);

System.out.println(update);
}


* 打印结果
* ==> Preparing: UPDATE user SET name=?, status=? WHERE name = ?
* ==> Parameters: zhangsan(String), true(Boolean), lqf(String)
* <== Updates: 100

posted on 2019-11-06 14:09  shenhaha  阅读(417)  评论(0编辑  收藏  举报

有用的话麻烦点个推荐哈