Closed
Description
org.apache.ibatis.reflection.ParamNameResolver#getNamedParams
public Object getNamedParams(Object[] args) {
final int paramCount = names.size();
if (args == null || paramCount == 0) {
return null;
} else if (!hasParamAnnotation && paramCount == 1) {
Object value = args[names.firstKey()];
return wrapToMapIfCollection(value, useActualParamName ? names.get(0) : null); //--------$1
} else {
......
}
}
code line $1 'names.get(0)' should be replaced by 'names.get(names.firstKey())' . because when 'paramCount == 1' names the only key is not necessarily 0,for example:
// when useActualParamName==true
public interface UserMapper {
List<User> selectByStartingWithName(RowBounds rb, List<String> nameList);
}
<select id="selectByStartingWithName" resultMap="baseMap">
select * from users where
<foreach collection="nameList" separator="or" item="item" open="(" close=")">
`name` LIKE concat('%',#{item},'%')
</foreach>
</select>
This test case 'names.size()==1' names contains key:1 --> value: "nameList"