Skip to content

Commit fc4c6f3

Browse files
committed
Merge branch 'master' into multi-row-insert-improvement-2
# Conflicts: # src/main/java/org/apache/ibatis/executor/keygen/Jdbc3KeyGenerator.java # src/test/java/org/apache/ibatis/submitted/keygen/Jdbc3KeyGeneratorTest.java
2 parents f575671 + 19a831b commit fc4c6f3

File tree

339 files changed

+4753
-7236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

339 files changed

+4753
-7236
lines changed

pom.xml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,13 @@
131131
</distributionManagement>
132132

133133
<properties>
134-
<maven.compiler.source>1.8</maven.compiler.source>
135-
<maven.compiler.target>1.8</maven.compiler.target>
136-
<maven.compiler.testTarget>1.8</maven.compiler.testTarget>
137-
<maven.compiler.testSource>1.8</maven.compiler.testSource>
138134
<maven.compiler.testCompilerArgument>-parameters</maven.compiler.testCompilerArgument>
139135
<clirr.comparisonVersion>3.3.1</clirr.comparisonVersion>
140136
<spotbugs.onlyAnalyze>org.apache.ibatis.*</spotbugs.onlyAnalyze>
141137
<osgi.export>org.apache.ibatis.*;version=${project.version};-noimport:=true</osgi.export>
142138
<osgi.import>*;resolution:=optional</osgi.import>
143139
<osgi.dynamicImport>*</osgi.dynamicImport>
144140
<maven.surefire.excludeGroups>org.apache.ibatis.test.SlowTests</maven.surefire.excludeGroups>
145-
146-
<!-- Override: Animal Sniffer Signature -->
147-
<signature.artifact>java18</signature.artifact>
148-
<signature.version>1.0</signature.version>
149141
</properties>
150142

151143
<dependencies>
@@ -204,7 +196,7 @@
204196
<dependency>
205197
<groupId>org.junit.vintage</groupId>
206198
<artifactId>junit-vintage-engine</artifactId>
207-
<version>5.1.0</version>
199+
<version>${junit-engine.version}</version>
208200
<scope>test</scope>
209201
</dependency>
210202
<dependency>

src/main/java/org/apache/ibatis/annotations/Lang.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2016 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
*/
1616
package org.apache.ibatis.annotations;
1717

18+
import org.apache.ibatis.scripting.LanguageDriver;
19+
1820
import java.lang.annotation.Documented;
1921
import java.lang.annotation.ElementType;
2022
import java.lang.annotation.Retention;
@@ -28,5 +30,5 @@
2830
@Retention(RetentionPolicy.RUNTIME)
2931
@Target(ElementType.METHOD)
3032
public @interface Lang {
31-
Class<?> value();
33+
Class<? extends LanguageDriver> value();
3234
}

src/main/java/org/apache/ibatis/binding/MapperMethod.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import org.apache.ibatis.mapping.MappedStatement;
2222
import org.apache.ibatis.mapping.SqlCommandType;
2323
import org.apache.ibatis.mapping.StatementType;
24-
import org.apache.ibatis.reflection.Jdk;
2524
import org.apache.ibatis.reflection.MetaObject;
26-
import org.apache.ibatis.reflection.OptionalUtil;
2725
import org.apache.ibatis.reflection.ParamNameResolver;
2826
import org.apache.ibatis.reflection.TypeParameterResolver;
2927
import org.apache.ibatis.session.Configuration;
@@ -86,7 +84,7 @@ public Object execute(SqlSession sqlSession, Object[] args) {
8684
result = sqlSession.selectOne(command.getName(), param);
8785
if (method.returnsOptional() &&
8886
(result == null || !method.getReturnType().equals(result.getClass()))) {
89-
result = OptionalUtil.ofNullable(result);
87+
result = Optional.ofNullable(result);
9088
}
9189
}
9290
break;
@@ -296,7 +294,7 @@ public MethodSignature(Configuration configuration, Class<?> mapperInterface, Me
296294
this.returnsVoid = void.class.equals(this.returnType);
297295
this.returnsMany = configuration.getObjectFactory().isCollection(this.returnType) || this.returnType.isArray();
298296
this.returnsCursor = Cursor.class.equals(this.returnType);
299-
this.returnsOptional = Jdk.optionalExists && Optional.class.equals(this.returnType);
297+
this.returnsOptional = Optional.class.equals(this.returnType);
300298
this.mapKey = getMapKey(method);
301299
this.returnsMap = this.mapKey != null;
302300
this.rowBoundsIndex = getUniqueParamIndex(method, RowBounds.class);

src/main/java/org/apache/ibatis/binding/MapperProxy.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
2323
import java.lang.reflect.Modifier;
2424
import java.util.Map;
2525

26-
import org.apache.ibatis.lang.UsesJava7;
2726
import org.apache.ibatis.reflection.ExceptionUtil;
2827
import org.apache.ibatis.session.SqlSession;
2928

@@ -60,15 +59,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
6059
}
6160

6261
private MapperMethod cachedMapperMethod(Method method) {
63-
MapperMethod mapperMethod = methodCache.get(method);
64-
if (mapperMethod == null) {
65-
mapperMethod = new MapperMethod(mapperInterface, method, sqlSession.getConfiguration());
66-
methodCache.put(method, mapperMethod);
67-
}
68-
return mapperMethod;
62+
return methodCache.computeIfAbsent(method, k -> new MapperMethod(mapperInterface, method, sqlSession.getConfiguration()));
6963
}
7064

71-
@UsesJava7
7265
private Object invokeDefaultMethod(Object proxy, Method method, Object[] args)
7366
throws Throwable {
7467
final Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class

src/main/java/org/apache/ibatis/binding/MapperProxyFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2015 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
public class MapperProxyFactory<T> {
2929

3030
private final Class<T> mapperInterface;
31-
private final Map<Method, MapperMethod> methodCache = new ConcurrentHashMap<Method, MapperMethod>();
31+
private final Map<Method, MapperMethod> methodCache = new ConcurrentHashMap<>();
3232

3333
public MapperProxyFactory(Class<T> mapperInterface) {
3434
this.mapperInterface = mapperInterface;
@@ -48,7 +48,7 @@ protected T newInstance(MapperProxy<T> mapperProxy) {
4848
}
4949

5050
public T newInstance(SqlSession sqlSession) {
51-
final MapperProxy<T> mapperProxy = new MapperProxy<T>(sqlSession, mapperInterface, methodCache);
51+
final MapperProxy<T> mapperProxy = new MapperProxy<>(sqlSession, mapperInterface, methodCache);
5252
return newInstance(mapperProxy);
5353
}
5454

src/main/java/org/apache/ibatis/binding/MapperRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2015 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
3434
public class MapperRegistry {
3535

3636
private final Configuration config;
37-
private final Map<Class<?>, MapperProxyFactory<?>> knownMappers = new HashMap<Class<?>, MapperProxyFactory<?>>();
37+
private final Map<Class<?>, MapperProxyFactory<?>> knownMappers = new HashMap<>();
3838

3939
public MapperRegistry(Configuration config) {
4040
this.config = config;
@@ -90,7 +90,7 @@ public Collection<Class<?>> getMappers() {
9090
* @since 3.2.2
9191
*/
9292
public void addMappers(String packageName, Class<?> superType) {
93-
ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>();
93+
ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<>();
9494
resolverUtil.find(new ResolverUtil.IsA(superType), packageName);
9595
Set<Class<? extends Class<?>>> mapperSet = resolverUtil.getClasses();
9696
for (Class<?> mapperClass : mapperSet) {

src/main/java/org/apache/ibatis/builder/BaseBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2015 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ protected Integer integerValueOf(String value, Integer defaultValue) {
6060

6161
protected Set<String> stringSetValueOf(String value, String defaultValue) {
6262
value = (value == null ? defaultValue : value);
63-
return new HashSet<String>(Arrays.asList(value.split(",")));
63+
return new HashSet<>(Arrays.asList(value.split(",")));
6464
}
6565

6666
protected JdbcType resolveJdbcType(String alias) {
@@ -108,7 +108,7 @@ protected Object createInstance(String alias) {
108108
}
109109
}
110110

111-
protected Class<?> resolveClass(String alias) {
111+
protected <T> Class<? extends T> resolveClass(String alias) {
112112
if (alias == null) {
113113
return null;
114114
}
@@ -145,7 +145,7 @@ protected TypeHandler<?> resolveTypeHandler(Class<?> javaType, Class<? extends T
145145
return handler;
146146
}
147147

148-
protected Class<?> resolveAlias(String alias) {
148+
protected <T> Class<? extends T> resolveAlias(String alias) {
149149
return typeAliasRegistry.resolveAlias(alias);
150150
}
151151
}

src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -188,7 +188,7 @@ public ResultMap addResultMap(
188188
throw new IncompleteElementException("Could not find a parent resultmap with id '" + extend + "'");
189189
}
190190
ResultMap resultMap = configuration.getResultMap(extend);
191-
List<ResultMapping> extendedResultMappings = new ArrayList<ResultMapping>(resultMap.getResultMappings());
191+
List<ResultMapping> extendedResultMappings = new ArrayList<>(resultMap.getResultMappings());
192192
extendedResultMappings.removeAll(resultMappings);
193193
// Remove parent constructor if this resultMap declares a constructor.
194194
boolean declaresConstructor = false;
@@ -237,7 +237,7 @@ public Discriminator buildDiscriminator(
237237
null,
238238
null,
239239
false);
240-
Map<String, String> namespaceDiscriminatorMap = new HashMap<String, String>();
240+
Map<String, String> namespaceDiscriminatorMap = new HashMap<>();
241241
for (Map.Entry<String, String> e : discriminatorMap.entrySet()) {
242242
String resultMap = e.getValue();
243243
resultMap = applyCurrentNamespace(resultMap, true);
@@ -320,7 +320,7 @@ private ParameterMap getStatementParameterMap(
320320
throw new IncompleteElementException("Could not find parameter map " + parameterMapName, e);
321321
}
322322
} else if (parameterTypeClass != null) {
323-
List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
323+
List<ParameterMapping> parameterMappings = new ArrayList<>();
324324
parameterMap = new ParameterMap.Builder(
325325
configuration,
326326
statementId + "-Inline",
@@ -336,7 +336,7 @@ private List<ResultMap> getStatementResultMaps(
336336
String statementId) {
337337
resultMap = applyCurrentNamespace(resultMap, true);
338338

339-
List<ResultMap> resultMaps = new ArrayList<ResultMap>();
339+
List<ResultMap> resultMaps = new ArrayList<>();
340340
if (resultMap != null) {
341341
String[] resultMapNames = resultMap.split(",");
342342
for (String resultMapName : resultMapNames) {
@@ -392,7 +392,7 @@ public ResultMapping buildResultMapping(
392392
}
393393

394394
private Set<String> parseMultipleColumnNames(String columnName) {
395-
Set<String> columns = new HashSet<String>();
395+
Set<String> columns = new HashSet<>();
396396
if (columnName != null) {
397397
if (columnName.indexOf(',') > -1) {
398398
StringTokenizer parser = new StringTokenizer(columnName, "{}, ", false);
@@ -408,7 +408,7 @@ private Set<String> parseMultipleColumnNames(String columnName) {
408408
}
409409

410410
private List<ResultMapping> parseCompositeColumnName(String columnName) {
411-
List<ResultMapping> composites = new ArrayList<ResultMapping>();
411+
List<ResultMapping> composites = new ArrayList<>();
412412
if (columnName != null && (columnName.indexOf('=') > -1 || columnName.indexOf(',') > -1)) {
413413
StringTokenizer parser = new StringTokenizer(columnName, "{}=, ", false);
414414
while (parser.hasMoreTokens()) {
@@ -472,7 +472,7 @@ public ResultMapping buildResultMapping(
472472
nestedResultMap, notNullColumn, columnPrefix, typeHandler, flags, null, null, configuration.isLazyLoadingEnabled());
473473
}
474474

475-
public LanguageDriver getLanguageDriver(Class<?> langClass) {
475+
public LanguageDriver getLanguageDriver(Class<? extends LanguageDriver> langClass) {
476476
if (langClass != null) {
477477
configuration.getLanguageRegistry().register(langClass);
478478
} else {

src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ public SqlSource parse(String originalSql, Class<?> parameterType, Map<String, O
4848

4949
private static class ParameterMappingTokenHandler extends BaseBuilder implements TokenHandler {
5050

51-
private List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
51+
private List<ParameterMapping> parameterMappings = new ArrayList<>();
5252
private Class<?> parameterType;
5353
private MetaObject metaParameters;
5454

src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import org.apache.ibatis.mapping.SqlSource;
8282
import org.apache.ibatis.mapping.StatementType;
8383
import org.apache.ibatis.parsing.PropertyParser;
84-
import org.apache.ibatis.reflection.Jdk;
8584
import org.apache.ibatis.reflection.TypeParameterResolver;
8685
import org.apache.ibatis.scripting.LanguageDriver;
8786
import org.apache.ibatis.session.Configuration;
@@ -245,7 +244,7 @@ private String generateResultMapName(Method method) {
245244
}
246245

247246
private void applyResultMap(String resultMapId, Class<?> returnType, Arg[] args, Result[] results, TypeDiscriminator discriminator) {
248-
List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
247+
List<ResultMapping> resultMappings = new ArrayList<>();
249248
applyConstructorArgs(args, returnType, resultMappings);
250249
applyResults(results, returnType, resultMappings);
251250
Discriminator disc = applyDiscriminator(resultMapId, returnType, discriminator);
@@ -258,7 +257,7 @@ private void createDiscriminatorResultMaps(String resultMapId, Class<?> resultTy
258257
if (discriminator != null) {
259258
for (Case c : discriminator.cases()) {
260259
String caseResultMapId = resultMapId + "-" + c.value();
261-
List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
260+
List<ResultMapping> resultMappings = new ArrayList<>();
262261
// issue #136
263262
applyConstructorArgs(c.constructArgs(), resultType, resultMappings);
264263
applyResults(c.results(), resultType, resultMappings);
@@ -277,7 +276,7 @@ private Discriminator applyDiscriminator(String resultMapId, Class<?> resultType
277276
Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>)
278277
(discriminator.typeHandler() == UnknownTypeHandler.class ? null : discriminator.typeHandler());
279278
Case[] cases = discriminator.cases();
280-
Map<String, String> discriminatorMap = new HashMap<String, String>();
279+
Map<String, String> discriminatorMap = new HashMap<>();
281280
for (Case c : cases) {
282281
String value = c.value();
283282
String caseResultMapId = resultMapId + "-" + value;
@@ -383,7 +382,7 @@ void parseStatement(Method method) {
383382

384383
private LanguageDriver getLanguageDriver(Method method) {
385384
Lang lang = method.getAnnotation(Lang.class);
386-
Class<?> langClass = null;
385+
Class<? extends LanguageDriver> langClass = null;
387386
if (lang != null) {
388387
langClass = lang.value();
389388
}
@@ -451,7 +450,7 @@ private Class<?> getReturnType(Method method) {
451450
returnType = (Class<?>) ((ParameterizedType) returnTypeParameter).getRawType();
452451
}
453452
}
454-
} else if (Jdk.optionalExists && Optional.class.equals(rawType)) {
453+
} else if (Optional.class.equals(rawType)) {
455454
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
456455
Type returnTypeParameter = actualTypeArguments[0];
457456
if (returnTypeParameter instanceof Class<?>) {
@@ -537,7 +536,7 @@ private Class<? extends Annotation> chooseAnnotationType(Method method, Set<Clas
537536

538537
private void applyResults(Result[] results, Class<?> resultType, List<ResultMapping> resultMappings) {
539538
for (Result result : results) {
540-
List<ResultFlag> flags = new ArrayList<ResultFlag>();
539+
List<ResultFlag> flags = new ArrayList<>();
541540
if (result.id()) {
542541
flags.add(ResultFlag.ID);
543542
}
@@ -593,7 +592,7 @@ private boolean hasNestedSelect(Result result) {
593592

594593
private void applyConstructorArgs(Arg[] args, Class<?> resultType, List<ResultMapping> resultMappings) {
595594
for (Arg arg : args) {
596-
List<ResultFlag> flags = new ArrayList<ResultFlag>();
595+
List<ResultFlag> flags = new ArrayList<>();
597596
flags.add(ResultFlag.CONSTRUCTOR);
598597
if (arg.id()) {
599598
flags.add(ResultFlag.ID);

0 commit comments

Comments
 (0)