Skip to content

Commit c420c85

Browse files
committed
Get languageDriver via mapperMethod, remove the new constructor.
1 parent e4b895f commit c420c85

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterT
476476
return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
477477
} else if (sqlProviderAnnotationType != null) {
478478
Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
479-
return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method, languageDriver);
479+
return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
480480
}
481481
return null;
482482
} catch (Exception e) {

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import java.lang.reflect.Method;
1919
import java.lang.reflect.Modifier;
20-
import java.util.HashMap;
2120
import java.util.Map;
2221

22+
import org.apache.ibatis.annotations.Lang;
2323
import org.apache.ibatis.builder.BuilderException;
2424
import org.apache.ibatis.mapping.BoundSql;
2525
import org.apache.ibatis.mapping.SqlSource;
@@ -55,17 +55,11 @@ public ProviderSqlSource(Configuration configuration, Object provider) {
5555
* @since 3.4.5
5656
*/
5757
public ProviderSqlSource(Configuration configuration, Object provider, Class<?> mapperType, Method mapperMethod) {
58-
this(configuration, provider, mapperType, mapperMethod, configuration.getDefaultScriptingLanguageInstance());
59-
}
60-
61-
/**
62-
* @since 3.4.6
63-
*/
64-
public ProviderSqlSource(Configuration configuration, Object provider, Class<?> mapperType, Method mapperMethod, LanguageDriver languageDriver) {
6558
String providerMethodName;
6659
try {
6760
this.configuration = configuration;
68-
this.languageDriver = languageDriver;
61+
Lang lang = mapperMethod.getAnnotation(Lang.class);
62+
this.languageDriver = configuration.getLanguageRegistry().getDriver(lang == null ? configuration.getLanguageRegistry().getDefaultDriverClass() : lang.value());
6963
this.providerType = (Class<?>) provider.getClass().getMethod("type").invoke(provider);
7064
providerMethodName = (String) provider.getClass().getMethod("method").invoke(provider);
7165

0 commit comments

Comments
 (0)