Browse Source

新属性

miemie 5 years ago
parent
commit
b7236ea765

+ 8 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableFieldInfo.java

@@ -41,6 +41,12 @@ import java.lang.reflect.Field;
 @EqualsAndHashCode
 public class TableFieldInfo implements Constants {
 
+    /**
+     * 属性
+     *
+     * @since 3.3.1
+     */
+    private final Field field;
     /**
      * 字段名
      */
@@ -146,6 +152,7 @@ public class TableFieldInfo implements Constants {
      */
     @SuppressWarnings("unchecked")
     public TableFieldInfo(GlobalConfig.DbConfig dbConfig, TableInfo tableInfo, Field field, TableField tableField) {
+        this.field = field;
         this.version = field.getAnnotation(Version.class) != null;
         this.property = field.getName();
         this.propertyType = field.getType();
@@ -238,6 +245,7 @@ public class TableFieldInfo implements Constants {
      * 不存在 TableField 注解时, 使用的构造函数
      */
     public TableFieldInfo(GlobalConfig.DbConfig dbConfig, TableInfo tableInfo, Field field) {
+        this.field = field;
         this.version = field.getAnnotation(Version.class) != null;
         this.property = field.getName();
         this.propertyType = field.getType();

+ 1 - 1
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/OptimisticLockerInterceptor.java

@@ -179,7 +179,7 @@ public class OptimisticLockerInterceptor implements Interceptor {
     }
 
     private EntityField getVersionField(Class<?> parameterClass, TableInfo tableInfo) {
-        return versionFieldCache.computeIfAbsent(parameterClass, mapping -> getVersionFieldRegular(parameterClass, tableInfo));
+        return versionFieldCache.computeIfAbsent(parameterClass, mapping -> getVersionFieldRegular(mapping, tableInfo));
     }
 
     /**