MyBatis paramType类型为集合
Posted miye
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MyBatis paramType类型为集合相关的知识,希望对你有一定的参考价值。
1 Array
<select id="queryPojoById" parameterType="String[]" resultMap="pojo"> select * from t_table where id in <foreach collection="array" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </select>
2 list
<select id="queryPojoById" parameterType="list" resultMap="pojo">
select * from t_table where id in
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
3 Map
<select id="queryPojoById" parameterType="map" resultMap="pojo"> select * from t_table where id in <foreach collection="ids" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </select>
这里的ids指的的是你放入map里面的key
以上是关于MyBatis paramType类型为集合的主要内容,如果未能解决你的问题,请参考以下文章