mybatis/old-google-code-issues

Maps inside <foreach> - ${index} is replaced as 0,1,2... not map key

Closed this issue · 0 comments

MyBatis version 3.2.1

<foreach collection="filters" index="key" item="value" separator="AND">
 UPPER(TRIM(${key})) = UPPER(TRIM(#{value}))
</foreach>

filters is Map<String,String>
In example above ${key} is replaced by ordinal number - 0, 1, 2 etc.
When I change to #{key} it is replace by true map key but query is not usable 
since I need column name, not property.

Maybe it's good idea to use value.key/value.value and leave index for ordinal 
numbering?

Original issue reported on code.google.com by monika1m...@interia.pl on 15 Mar 2013 at 2:07