Browse Source

不再尝试获取父类的 tableinfo 信息

miemie 6 years ago
parent
commit
f2131743b9

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

@@ -68,10 +68,6 @@ public class TableFieldInfo implements Constants {
      * 字段策略【 默认,自判断 null 】
      */
     private final FieldStrategy fieldStrategy;
-    /**
-     * 标记该字段属于哪个类
-     */
-    private final Class<?> clazz;
     /**
      * 是否进行 select 查询
      * <p>大字段可设置为 false 不加入 select 查询范围</p>
@@ -117,7 +113,6 @@ public class TableFieldInfo implements Constants {
         this.propertyType = field.getType();
         this.isCharSequence = StringUtils.isCharSequence(this.propertyType);
         this.fieldFill = tableField.fill();
-        this.clazz = field.getDeclaringClass();
         this.update = tableField.update();
         this.el = el;
         tableInfo.setLogicDelete(this.initLogicDelete(dbConfig, field));
@@ -162,7 +157,6 @@ public class TableFieldInfo implements Constants {
         this.el = field.getName();
         this.fieldStrategy = dbConfig.getFieldStrategy();
         this.setCondition(dbConfig);
-        this.clazz = field.getDeclaringClass();
         tableInfo.setLogicDelete(this.initLogicDelete(dbConfig, field));
 
         String column = field.getName();

+ 0 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableInfo.java

@@ -95,10 +95,6 @@ public class TableInfo implements Constants {
      * 是否开启下划线转驼峰
      */
     private boolean underCamel = true;
-    /**
-     * 标记该字段属于哪个类
-     */
-    private Class<?> clazz;
     /**
      * 缓存包含主键及字段的 sql select
      */

+ 2 - 17
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/TableInfoHelper.java

@@ -77,20 +77,7 @@ public class TableInfoHelper {
             || clazz == String.class) {
             return null;
         }
-        TableInfo tableInfo = TABLE_INFO_CACHE.get(ClassUtils.getUserClass(clazz));
-        if (null != tableInfo) {
-            return tableInfo;
-        }
-        //尝试获取父类缓存
-        Class<?> currentClass = clazz;
-        while (null == tableInfo && Object.class != currentClass) {
-            currentClass = currentClass.getSuperclass();
-            tableInfo = TABLE_INFO_CACHE.get(ClassUtils.getUserClass(currentClass));
-        }
-        if (tableInfo != null) {
-            TABLE_INFO_CACHE.put(ClassUtils.getUserClass(clazz), tableInfo);
-        }
-        return tableInfo;
+        return TABLE_INFO_CACHE.get(ClassUtils.getUserClass(clazz));
     }
 
     /**
@@ -338,7 +325,6 @@ public class TableInfoHelper {
                     }
                 }
                 tableInfo.setKeyRelated(checkRelated(underCamel, field.getName(), column))
-                    .setClazz(field.getDeclaringClass())
                     .setKeyColumn(column)
                     .setKeyProperty(field.getName());
                 return true;
@@ -370,8 +356,7 @@ public class TableInfoHelper {
                 tableInfo.setKeyRelated(checkRelated(tableInfo.isUnderCamel(), field.getName(), column))
                     .setIdType(dbConfig.getIdType())
                     .setKeyColumn(column)
-                    .setKeyProperty(field.getName())
-                    .setClazz(field.getDeclaringClass());
+                    .setKeyProperty(field.getName());
                 return true;
             } else {
                 throwExceptionId(clazz);