Skip to content

Commit 3f19d04

Browse files
committed
#549 Changed the default value of useActualParamName to true. False is useful only when the legacy style parameter reference (i.e. #{0}, #{1}, ...) is used.
1 parent 104988d commit 3f19d04

File tree

8 files changed

+10
-8
lines changed

8 files changed

+10
-8
lines changed

src/main/java/org/apache/ibatis/reflection/ParamNameResolver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public ParamNameResolver(Configuration config, Method method) {
8787
// @Param was not specified.
8888
if (config.isUseActualParamName()) {
8989
name = getActualParamName(method, paramIndex);
90-
} else {
90+
}
91+
if (name == null) {
9192
// use the parameter index as the name ("0", "1", ...)
9293
// gcode issue #71
9394
name = String.valueOf(map.size());
@@ -100,7 +101,7 @@ public ParamNameResolver(Configuration config, Method method) {
100101

101102
private String getActualParamName(Method method, int paramIndex) {
102103
if (GET_PARAMS == null) {
103-
throw new ReflectionException("Method#getParameters() method does not exist. Relaunch on Java 8 or set false to useActualParamName.");
104+
return null;
104105
}
105106
try {
106107
Object[] params = (Object[]) GET_PARAMS.invoke(method);

src/main/java/org/apache/ibatis/session/Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public class Configuration {
106106
protected boolean useColumnLabel = true;
107107
protected boolean cacheEnabled = true;
108108
protected boolean callSettersOnNulls = false;
109-
protected boolean useActualParamName = false;
109+
protected boolean useActualParamName = true;
110110

111111
protected String logPrefix;
112112
protected Class <? extends Log> logImpl;

src/site/es/xdoc/configuration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
445445
true | false
446446
</td>
447447
<td>
448-
false
448+
true
449449
</td>
450450
</tr>
451451
</tbody>

src/site/ja/xdoc/configuration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
475475
true | false
476476
</td>
477477
<td>
478-
false
478+
true
479479
</td>
480480
</tr>
481481
</tbody>

src/site/ko/xdoc/configuration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
452452
true | false
453453
</td>
454454
<td>
455-
false
455+
true
456456
</td>
457457
</tr>
458458
</tbody>

src/site/xdoc/configuration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
536536
true | false
537537
</td>
538538
<td>
539-
false
539+
true
540540
</td>
541541
</tr>
542542
</tbody>

src/site/zh/xdoc/configuration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
456456
true | false
457457
</td>
458458
<td>
459-
false
459+
true
460460
</td>
461461
</tr>
462462
</tbody>

src/test/java/org/apache/ibatis/binding/BindingTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public static void setup() throws Exception {
6969
Environment environment = new Environment("Production", transactionFactory, dataSource);
7070
Configuration configuration = new Configuration(environment);
7171
configuration.setLazyLoadingEnabled(true);
72+
configuration.setUseActualParamName(false); // to test legacy style reference (#{0} #{1})
7273
configuration.getTypeAliasRegistry().registerAlias(Blog.class);
7374
configuration.getTypeAliasRegistry().registerAlias(Post.class);
7475
configuration.getTypeAliasRegistry().registerAlias(Author.class);

0 commit comments

Comments
 (0)