mybatis 动态参数及其 foreach collection使用
Mybatis里传参数入Mapper一般基于基本类型,Integer、String、List、Hashtable,然后以此构架foreach迭代动态sql。
1 2 3 4 5 6 7 8 |
<select id="findUserListByIdList" parameterType="java.util.ArrayList" resultType="User"> select * from user user <where> user.id in <foreach collection="listName" item="guard" index="index" separator="," open="(" separator="," close=")" > #{guard} </foreach> </where> </select> |