diff --git a/src/main/java/org/apache/ibatis/reflection/ParamNameResolver.java b/src/main/java/org/apache/ibatis/reflection/ParamNameResolver.java index f6b993a7507..e47c51ca218 100644 --- a/src/main/java/org/apache/ibatis/reflection/ParamNameResolver.java +++ b/src/main/java/org/apache/ibatis/reflection/ParamNameResolver.java @@ -125,7 +125,7 @@ public Object getNamedParams(Object[] args) { return null; } else if (!hasParamAnnotation && paramCount == 1) { Object value = args[names.firstKey()]; - return wrapToMapIfCollection(value, useActualParamName ? names.get(0) : null); + return wrapToMapIfCollection(value, useActualParamName ? names.get(names.firstKey()) : null); } else { final Map param = new ParamMap<>(); int i = 0; diff --git a/src/test/java/org/apache/ibatis/submitted/param_name_resolve/ActualParamNameTest.java b/src/test/java/org/apache/ibatis/submitted/param_name_resolve/ActualParamNameTest.java index 570aea64449..8d00bcf1955 100644 --- a/src/test/java/org/apache/ibatis/submitted/param_name_resolve/ActualParamNameTest.java +++ b/src/test/java/org/apache/ibatis/submitted/param_name_resolve/ActualParamNameTest.java @@ -25,6 +25,7 @@ import org.apache.ibatis.annotations.Select; import org.apache.ibatis.io.Resources; import org.apache.ibatis.jdbc.ScriptRunner; +import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; @@ -72,6 +73,11 @@ void testSingleListParameterWhenUseActualParamNameIsTrue() { long count = mapper.getUserCountUsingListWithAliasIsList(Arrays.asList(1, 2)); assertEquals(2, count); } + // use actual name #2693 + { + long count = mapper.getUserCountUsingList_RowBounds(new RowBounds(0, 5), Arrays.asList(1, 2)); + assertEquals(2, count); + } } } @@ -142,6 +148,16 @@ interface Mapper { "" }) Long getUserCountUsingArrayWithAliasArray(Integer... ids); + + @Select({ + "" + }) + Long getUserCountUsingList_RowBounds(RowBounds rowBounds, List ids); } }