miemie 5 年之前
父節點
當前提交
727fed4adb

+ 2 - 0
OVERRIDE_CLASS.md

@@ -1,5 +1,7 @@
 ### mybatis
 - `2019-10-25`: MybatisConfiguration > [Configuration](https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/session/Configuration.java)
+- `2019-2-3`: MybatisDefaultParameterHandler > [DefaultParameterHandler](https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/scripting/defaults/DefaultParameterHandler.java)
+- `2019-11-1`: MybatisMapperAnnotationBuilder > [MapperAnnotationBuilder](https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/scripting/defaults/DefaultParameterHandler.java)
 
 ### mybatis-spring
 - todo

+ 8 - 14
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMapperAnnotationBuilder.java

@@ -57,7 +57,7 @@ import java.util.*;
 /**
  * 继承
  * <p>
- * 只重写了 {@link MapperAnnotationBuilder#parse}
+ * 只重写了 {@link MapperAnnotationBuilder#parse} 和 #getReturnType
  * 没有XML配置文件注入基础CRUD方法
  * </p>
  *
@@ -207,11 +207,11 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
 
     private String parseResultMap(Method method) {
         Class<?> returnType = getReturnType(method);
-        ConstructorArgs args = method.getAnnotation(ConstructorArgs.class);
-        Results results = method.getAnnotation(Results.class);
+        Arg[] args = method.getAnnotationsByType(Arg.class);
+        Result[] results = method.getAnnotationsByType(Result.class);
         TypeDiscriminator typeDiscriminator = method.getAnnotation(TypeDiscriminator.class);
         String resultMapId = generateResultMapName(method);
-        applyResultMap(resultMapId, returnType, argsIf(args), resultsIf(results), typeDiscriminator);
+        applyResultMap(resultMapId, returnType, args, results, typeDiscriminator);
         return resultMapId;
     }
 
@@ -285,7 +285,7 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
             Integer fetchSize = null;
             Integer timeout = null;
             StatementType statementType = StatementType.PREPARED;
-            ResultSetType resultSetType = null;
+            ResultSetType resultSetType = configuration.getDefaultResultSetType();
             SqlCommandType sqlCommandType = getSqlCommandType(method);
             boolean isSelect = sqlCommandType == SqlCommandType.SELECT;
             boolean flushCache = !isSelect;
@@ -321,7 +321,9 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
                 fetchSize = options.fetchSize() > -1 || options.fetchSize() == Integer.MIN_VALUE ? options.fetchSize() : null; //issue #348
                 timeout = options.timeout() > -1 ? options.timeout() : null;
                 statementType = options.statementType();
-                resultSetType = options.resultSetType();
+                if (options.resultSetType() != ResultSetType.DEFAULT) {
+                    resultSetType = options.resultSetType();
+                }
             }
 
             String resultMapId = null;
@@ -614,14 +616,6 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
         return value == null || value.trim().length() == 0 ? null : value;
     }
 
-    private Result[] resultsIf(Results results) {
-        return results == null ? new Result[0] : results.value();
-    }
-
-    private Arg[] argsIf(ConstructorArgs args) {
-        return args == null ? new Arg[0] : args.value();
-    }
-
     private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
         String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
         Class<?> resultTypeClass = selectKeyAnnotation.resultType();