IIWAB mybatisplus乐观锁 - IIWAB

mybatisplus乐观锁

IIWAB 1年前 ⋅ 6887 阅读

依赖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;


全部评论: 0

    我有话说: