当前使用版本(必须填写清楚,否则不予处理)
updateById 当同时使用乐观锁和自动填充的时候,updateTime反复更新时,最终只更新了一次,
v3.3.0 ----updateTime一次也不更新
v3.3.1-----updateTime只更新了一次 执行语句,反复执行,只有版本号更新了,但是updateTime没有更新
该问题是怎么引起的?(最新版上已修复的会直接close掉)
重现步骤
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime updateTime;
@Version
private Integer version;//版本
//test
@Test
void updateVersion() {
//先查询
LambdaQueryWrapper
//后更新
// User user = new User(); // user.setVersion(2); user.setAge(30); user.setId(1094590409767661570L); int rows = userMapper.updateById(user); System.out.println("更新影响行数:" + rows); }
@Override
public void updateFill(MetaObject metaObject) {
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); // 起始版本 3.3.0(推荐使用)
}
报错信息
//sql 执行语句,反复执行,只有版本号更新了,但是更新时间没有更新 DEBUG==> Preparing: SELECT id,name,age,email,manager_id,create_time,update_time,version FROM user WHERE deleted=0 AND (name = ?) DEBUG==> Parameters: 张雨琪(String) TRACE<== Columns: id, name, age, email, manager_id, create_time, update_time, version TRACE<== Row: 1094590409767661570, 张雨琪, 30, zjq@baomidou.com, 1088248166370832385, 2019-01-14 09:15:15, 2020-04-01 13:25:15, 5 DEBUG<== Total: 1 DEBUG==> Preparing: UPDATE user SET name=?, age=?, email=?, manager_id=?, create_time=?, update_time=?, version=? WHERE id=? AND version=? AND deleted=0 DEBUG==> Parameters: 张雨琪(String), 30(Integer), zjq@baomidou.com(String), 1088248166370832385(Long), 2019-01-14T09:15:15(LocalDateTime), 2020-04-01T13:25:15(LocalDateTime), 6(Integer), 1094590409767661570(Long), 5(Integer) DEBUG<== Updates: 1 更新影响行数:1
Comment From: jmuchch
经反复测试,确实存在这样的问题
Comment From: miemieYaho
默认规则有值不填充
Comment From: jmuchch
应该每次更新记录,updateTime都应该更新的吧
Comment From: jmuchch
比如,age,修改了,updateTime不也应该更新一次吗?
Comment From: miemieYaho
自己点开strictUpdateFill看
Comment From: jmuchch
thanks
------------------ 原始邮件 ------------------ 发件人: "notifications"<notifications@github.com>; 发送时间: 2020年4月1日(星期三) 下午4:50 收件人: "baomidou/mybatis-plus"<mybatis-plus@noreply.github.com>; 抄送: "阿波才"<837662459@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [baomidou/mybatis-plus] updateById 当同时使用乐观锁和自动填充的时候,updateTime字段在反复执行更新操作时,最终只更新了一次, (#2307)
自己点开strictUpdateFill看
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Comment From: okcgogogo
这个问题3.3.2已经解决了,建议使用最新的版本当前最新版本是3.4.1