类 OptimisticLockerInnerInterceptor
java.lang.Object
com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor
- 所有已实现的接口:
InnerInterceptor
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 OptimisticLockerInnerInterceptor into mybatis plugin.
How to work?
if update entity with version column=1:
(1) no OptimisticLockerInnerInterceptor:
SQL: update tbl_test set name='abc' where id=100001;
(2) add OptimisticLockerInnerInterceptor:
SQL: update tbl_test set name='abc',version=2 where id=100001 and version=1;
- 从以下版本开始:
- 3.4.0
- 作者:
- yuxiaobin
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidbeforeUpdate(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement ms, Object parameter) Executor.update(MappedStatement, Object)操作前置处理protected voiddoOptimisticLocker(Map<String, Object> map, String msId) protected ObjectgetUpdatedVersionVal(Class<?> clazz, Object originalVersionVal) This method provides the control for version value.
Returned value type must be the same as original one.protected com.baomidou.mybatisplus.core.metadata.TableFieldInfogetVersionFieldInfo(Class<?> entityClazz) voidsetException(RuntimeException exception) 自定义异常处理从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor
beforeGetBoundSql, beforePrepare, beforeQuery, setProperties, willDoQuery, willDoUpdate
-
构造器详细资料
-
OptimisticLockerInnerInterceptor
public OptimisticLockerInnerInterceptor() -
OptimisticLockerInnerInterceptor
public OptimisticLockerInnerInterceptor(boolean wrapperMode)
-
-
方法详细资料
-
beforeUpdate
public void beforeUpdate(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement ms, Object parameter) 从接口复制的说明:InnerInterceptorExecutor.update(MappedStatement, Object)操作前置处理改改sql啥的
- 指定者:
beforeUpdate在接口中InnerInterceptor- 参数:
executor- Executor(可能是代理对象)ms- MappedStatementparameter- parameter
-
doOptimisticLocker
-
getVersionFieldInfo
protected com.baomidou.mybatisplus.core.metadata.TableFieldInfo getVersionFieldInfo(Class<?> entityClazz) -
getUpdatedVersionVal
This method provides the control for version value.
Returned value type must be the same as original one.- 参数:
originalVersionVal- ignore- 返回:
- updated version val
-
setException
自定义异常处理
-