今天使用MyBatis3 编写批量更新接口提示如下错误信息:org.apache.ibatis.builder.BuilderException: The expression 'array' evaluated to a null value.
错误代码:
<if test="archSids != null">
and arch_sid in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
正确代码:
<if test="archSids != null">
and arch_sid in
<foreach collection="archSids" item="archSids" open="(" separator="," close=")">
#{archSids}
</foreach>
</if>
service 调用mapper 接口:
paramter.put("archSids", archSids);
List<Map<String, Long>> statistics = fileMapper.getStatistics(paramter);
结论:传参和接收参数不匹配,导致如上所述的错误信息