在springboot+MP 项目中使用乐观锁遇到的问题





使用乐观锁的东西我都配置了
第一种问题(找不到字段,直接测试失败)
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'MP_OPTLOCK_VERSION_ORIGINAL' not found. Available parameters are [param1, et]
第二种问题: (version字段为null导致无法更新数据,测试成功但是因为Version字段为null无法满足条件)
[main] [cn.itcast.mp.mapper.UserMapper.updateById]-[DEBUG] ==> Preparing: UPDATE tb_user SET age=?, version=? WHERE id=? AND version=?
[main] [cn.itcast.mp.mapper.UserMapper.updateById]-[DEBUG] ==> Parameters: 1000(Integer), 1(Integer), 2(Long), null
Consume Time:1 ms 2023-06-09 23:08:25:355
[main] [cn.itcast.mp.mapper.UserMapper.updateById]-[DEBUG] <== Updates: 0
Execute SQL:UPDATE tb_user SET age=1000, version=1 WHERE id=2 AND version=NULL
求达答案