依赖Maven: com.baomidou:mybatis-plus-extension:3.1.0
Optimistic Lock Light version
Intercept on Executor.update; Support version types: int/Integer, long/Long, java.util.Date, java.sql.Timestamp For extra types, please define a subclass and override getUpdatedVersionVal() method.
How to use?
(1) Define an Entity and add Version annotation on one entity field. (2) Add OptimisticLockerInterceptor into mybatis plugin.
How to work?
if update entity with version column=1: (1) no OptimisticLockerInterceptor: SQL: update tbl_test set name='abc' where id=100001; (2) add OptimisticLockerInterceptor: SQL: update tbl_test set name='abc',version=2 where id=100001 and version=1;
注意:本文归作者所有,未经作者允许,不得转载