Browse Source

修复 Gitee issues/ILEYD

hubin 7 năm trước cách đây
mục cha
commit
32e65f161b

+ 10 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/AbstractMethod.java

@@ -37,6 +37,7 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.core.config.GlobalConfig;
 import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
 import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
@@ -66,7 +67,15 @@ public abstract class AbstractMethod {
         languageDriver = configuration.getDefaultScriptingLanguageInstance();
         Class<?> modelClass = extractModelClass(mapperClass);
         if (null != modelClass) {
-            // 注入自定义方法
+            /**
+             * 初始化 SQL 解析
+             */
+            if (this.getGlobalConfig().isSqlParserCache()) {
+                SqlParserHelper.initSqlParserInfoCache(mapperClass);
+            }
+            /**
+             * 注入自定义方法
+             */
             TableInfo tableInfo = TableInfoHelper.initTableInfo(builderAssistant, modelClass);
             injectMappedStatement(mapperClass, modelClass, tableInfo);
         }

+ 23 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/SqlParserHelper.java

@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.baomidou.mybatisplus.core.parser;
 
 import java.lang.reflect.Method;
@@ -9,6 +24,14 @@ import org.apache.ibatis.reflection.MetaObject;
 
 import com.baomidou.mybatisplus.annotation.SqlParser;
 
+/**
+ * <p>
+ * SQL 解析辅助类
+ * </p>
+ *
+ * @author hubin
+ * @since 2018-07-22
+ */
 public class SqlParserHelper {
 
     public static final String DELEGATE_MAPPED_STATEMENT = "delegate.mappedStatement";