Skip to content

Commit 7549f02

Browse files
committed
Fixes #121. @lang class is never registered.
1 parent f4ef461 commit 7549f02

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

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

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2013 the original author or authors.
2+
* Copyright 2009-2014 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.
@@ -505,33 +505,42 @@ public ResultMapping buildResultMapping(
505505
resultType, property, column, javaType, jdbcType, nestedSelect,
506506
nestedResultMap, notNullColumn, columnPrefix, typeHandler, flags, null, null);
507507
}
508-
509-
/** Backward compatibility signature */
510-
public MappedStatement addMappedStatement(
511-
String id,
512-
SqlSource sqlSource,
513-
StatementType statementType,
514-
SqlCommandType sqlCommandType,
515-
Integer fetchSize,
516-
Integer timeout,
517-
String parameterMap,
518-
Class<?> parameterType,
519-
String resultMap,
520-
Class<?> resultType,
521-
ResultSetType resultSetType,
522-
boolean flushCache,
523-
boolean useCache,
524-
boolean resultOrdered,
525-
KeyGenerator keyGenerator,
526-
String keyProperty,
527-
String keyColumn,
528-
String databaseId,
529-
LanguageDriver lang) {
530-
return addMappedStatement(
531-
id, sqlSource, statementType, sqlCommandType, fetchSize, timeout,
532-
parameterMap, parameterType, resultMap, resultType, resultSetType,
533-
flushCache, useCache, resultOrdered, keyGenerator, keyProperty,
534-
keyColumn, databaseId, lang, null);
508+
509+
public LanguageDriver getLanguageDriver(Class<?> langClass) {
510+
if (langClass != null) {
511+
configuration.getLanguageRegistry().register(langClass);
512+
} else {
513+
langClass = configuration.getLanguageRegistry().getDefaultDriverClass();
535514
}
515+
return configuration.getLanguageRegistry().getDriver(langClass);
516+
}
517+
518+
/** Backward compatibility signature */
519+
public MappedStatement addMappedStatement(
520+
String id,
521+
SqlSource sqlSource,
522+
StatementType statementType,
523+
SqlCommandType sqlCommandType,
524+
Integer fetchSize,
525+
Integer timeout,
526+
String parameterMap,
527+
Class<?> parameterType,
528+
String resultMap,
529+
Class<?> resultType,
530+
ResultSetType resultSetType,
531+
boolean flushCache,
532+
boolean useCache,
533+
boolean resultOrdered,
534+
KeyGenerator keyGenerator,
535+
String keyProperty,
536+
String keyColumn,
537+
String databaseId,
538+
LanguageDriver lang) {
539+
return addMappedStatement(
540+
id, sqlSource, statementType, sqlCommandType, fetchSize, timeout,
541+
parameterMap, parameterType, resultMap, resultType, resultSetType,
542+
flushCache, useCache, resultOrdered, keyGenerator, keyProperty,
543+
keyColumn, databaseId, lang, null);
544+
}
536545

537546
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2013 the original author or authors.
2+
* Copyright 2009-2014 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.
@@ -323,11 +323,11 @@ void parseStatement(Method method) {
323323

324324
private LanguageDriver getLanguageDriver(Method method) {
325325
Lang lang = method.getAnnotation(Lang.class);
326+
Class<?> langClass = null;
326327
if (lang != null) {
327-
Class<?> languageDriverClass = lang.value();
328-
return configuration.getLanguageRegistry().getDriver(languageDriverClass);
328+
langClass = lang.value();
329329
}
330-
return configuration.getLanguageRegistry().getDefaultDriver();
330+
return assistant.getLanguageDriver(langClass);
331331
}
332332

333333
private Class<?> getParameterType(Method method) {

src/main/java/org/apache/ibatis/builder/xml/XMLStatementBuilder.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2013 the original author or authors.
2+
* Copyright 2009-2014 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.
@@ -177,17 +177,11 @@ private boolean databaseIdMatchesCurrent(String id, String databaseId, String re
177177
}
178178

179179
private LanguageDriver getLanguageDriver(String lang) {
180-
Class<?> langClass;
181-
if (lang == null) {
182-
langClass = configuration.getLanguageRegistry().getDefaultDriverClass();
183-
} else {
180+
Class<?> langClass = null;
181+
if (lang != null) {
184182
langClass = resolveClass(lang);
185-
configuration.getLanguageRegistry().register(langClass);
186-
}
187-
if (langClass == null) {
188-
langClass = configuration.getLanguageRegistry().getDefaultDriverClass();
189183
}
190-
return configuration.getLanguageRegistry().getDriver(langClass);
184+
return builderAssistant.getLanguageDriver(langClass);
191185
}
192186

193187
}

0 commit comments

Comments
 (0)