HashMap的MyBatis参数 [英] MyBatis parameter from HashMap
本文介绍了HashMap的MyBatis参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在mapper界面中,我有:
In mapper interface I have:
ArrayList<Item> select(@Param("filterId")int filterId, @Param("filterData")HashMap<String,Object> filterData);
在mapper xml中,我有:
In mapper xml I have:
<select id="select" parameterType="map" resultMap="RM">
SELECT ...
FROM ....
WHERE id=#{filterData["id"]}
</select>
没有错误,但结果与预期不符(它返回空集,但我知道存在具有此类ID的项目). #{filterData ["id"]}似乎无效.我的错误在哪里?
No errors but the result is not as expected (it returns empty set but I know item with such id exists). The #{filterData["id"]} seems not to work. Where is my mistake?
推荐答案
我找到了答案:
<select id="select" parameterType="map" resultMap="RM">
SELECT ...
FROM ....
WHERE id=#{filterData.id}
</select>
这篇关于HashMap的MyBatis参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文