mybtis in 查询传入参数为list
1 如果传入参数只有一个且类型是List, 则在使用时,collection属性要必须指定为 list
例:
mapper.java
List<TYzglKhjls> selectWxlsByZyryBh(List<String> yxlsbhList);
mapper.xml
<select id="selectWxlsByZyryBh" resultMap="BaseResultMap"> select c_bh, c_zyry_bh, c_zyry_dh, c_lsxm, c_zjhm, c_lxdh, n_sfyx, c_ssdw from {db.t_yzgl_khjls} where n_sfyx = 1 and c_bh not in <foreach collection="list" item="item" open="(" separator="," close=")"> #{item} </foreach> </select>
2,如果传入参数使用了@Param(value="value"),collection的属性必须为"value"值
例:
mapper.java
List<TYzglKhjls> selectWxlsByZyryBh(@Param("zyrybh")String zyrybh, @Param("yxlsbhList")List<String> yxlsbhList);
mapper.xml
<select id="selectWxlsByZyryBh" resultMap="BaseResultMap"> select c_bh, c_zyry_bh, c_zyry_dh, c_lsxm, c_zjhm, c_lxdh, n_sfyx, c_ssdw from {db.t_yzgl_khjls} where c_zyry_bh = #{zyrybh} and n_sfyx = 1 <if test="yxlsbhList != null and yxlsbhList.size() > 0"> and c_bh in <foreach collection="yxlsbhList" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </select>