mapper interface:
List<Map<String, String>> selectXXXList(BeanA a);
BeanA:
private Map<String, String> map;
I need iterate this map in xxxMapper.xml. I tried in this way, but it can not work.
<select id = "selectXXXList" resultType="hashMap">
SELECT * FROM tableA
WHERE
1=1
<foreach collection="a.map.keys" item="item" index="index" open="" seperator="" close="">
AND ${item} = #{a.map[${item}]}
</foreach>
<select>
It is able to iterator the key in this way. But the value of hashMap #{a.map[${item}]}
does not work. Any idea? I can not change the interface BTW.
Try this :
<select id="selectXXXList" parameterType="beanA" resultType="hashmap">
select * from TABL where
<foreach collection="map" index="key" item="value" open="" separator=" and " close="">
${key}=#{value}
</foreach>
</select>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.