baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.41k stars 4.31k forks source link

mybatis-plus使用乐观锁更新是报异常 #6066

Closed gyfigher closed 6 months ago

gyfigher commented 6 months ago

当前使用版本(必填,否则不予处理)

3.4.0 ### 该问题是如何引起的?(确定最新版也有问题再提!!!) 应用多数据源配置,其中更新某张表,对update_time字段作为版本更新字段。配置好插件后,测试乐观锁更新,报Parameter 'MP_OPTLOCK_VERSION_ORIGINAL' not found ### 重现步骤(如果有就写完整) 数据库实体: ![image](https://github.com/baomidou/mybatis-plus/assets/49229749/e92740f4-9f5a-421b-9d26-40ea986196a8) 插件配置: ![image](https://github.com/baomidou/mybatis-plus/assets/49229749/760d42de-0c11-4596-9951-2aba5f9372c9) ![image](https://github.com/baomidou/mybatis-plus/assets/49229749/8d0286ee-f7f2-4efb-86ac-901964f3f169) 在执行测试的时候: DEBUG:乐观锁插件也配上了 ![image](https://github.com/baomidou/mybatis-plus/assets/49229749/ce79a542-4147-48ce-9489-8537a639a8c9) 再执行update的时候:却没找到这个插件 ![image](https://github.com/baomidou/mybatis-plus/assets/49229749/de756e45-6a02-4013-9e4e-cd3a5f5f30a5) ### 报错信息 Parameter 'MP_OPTLOCK_VERSION_ORIGINAL' not found
miemieYaho commented 6 months ago

你自己最小化项目排查吧

ttt307307 commented 1 month ago

this works for me

mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());