mybatis数组参数

Mybatis使用数组参数
1.使用

mapper接口代码
List getProvByIds(Long[] ids);
mapper.xml配置中的sql
    SELECT id, name from tab_province
    <where>
        id
    <foreach collection="array" item="id" separator="," open="in (" close=")">
        #{id}
    </foreach>
    </where>
</select> |  |

2.注意事项
不推荐使用数组传递where参数,因为使用数组传递where参数时,当ids数组为空时,并且没有进行判断直接执行sql,结果集不是空,反而是整个表的所有数据,具体原因继续分析咯