Pārlūkot izejas kodu

lambda 缓存获取优化

miemie 4 gadi atpakaļ
vecāks
revīzija
585f0a6746

+ 10 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractLambdaWrapper.java

@@ -15,7 +15,6 @@
  */
 package com.baomidou.mybatisplus.core.conditions;
 
-import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
 import com.baomidou.mybatisplus.core.toolkit.Assert;
 import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
@@ -75,13 +74,11 @@ public abstract class AbstractLambdaWrapper<T, Children extends AbstractLambdaWr
      * @see SerializedLambda#getImplClass()
      * @see SerializedLambda#getImplMethodName()
      */
-    private String getColumn(SerializedLambda lambda, boolean onlyColumn) throws MybatisPlusException {
-        String fieldName = PropertyNamer.methodToProperty(lambda.getImplMethodName());
+    private String getColumn(SerializedLambda lambda, boolean onlyColumn) {
         Class<?> aClass = lambda.getInstantiatedType();
         tryInitCache(aClass);
-        ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(fieldName));
-        Assert.notNull(columnCache, "can not find lambda cache for this property [%s] of entity [%s]",
-            fieldName, aClass.getName());
+        String fieldName = PropertyNamer.methodToProperty(lambda.getImplMethodName());
+        ColumnCache columnCache = getColumnCache(fieldName, aClass);
         return onlyColumn ? columnCache.getColumn() : columnCache.getColumnSelect();
     }
 
@@ -96,4 +93,11 @@ public abstract class AbstractLambdaWrapper<T, Children extends AbstractLambdaWr
         }
         Assert.notNull(columnMap, "can not find lambda cache for this entity [%s]", lambdaClass.getName());
     }
+
+    private ColumnCache getColumnCache(String fieldName, Class<?> lambdaClass) {
+        ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(fieldName));
+        Assert.notNull(columnCache, "can not find lambda cache for this property [%s] of entity [%s]",
+            fieldName, lambdaClass.getName());
+        return columnCache;
+    }
 }