mybatis中对List使用in语法,foreach语法

版权声明:转载请注明出处 https://blog.csdn.net/h2604396739/article/details/84330280

service中代码

    public Integer deleteAlarmCountResultLogical(String deleted, ArrayList<String> idList){
        HashMap<String, Object> map = new HashMap<>(4);

        map.put(”ids“,idList);
        map.put(”status“,deleted);
        return mapper.deleteAlarmCountResultLogical(map);
    }

mapper中接口代码

Integer deleteAlarmCountResultLogical(Map<String, Object> map);

xml文件中写法:
<update id="deleteAlarmCountResultLogical" parameterType="java.util.Map">
    update alarm_count_result set

    <if test="status != null and status != '' ">
        status = #{status}
    </if>
    where id in
    <!--这里的id对应map中的key-->
    <foreach close=")" collection="id" item="listItem" open="(" separator=",">
        #{listItem}
    </foreach>
</update>

猜你喜欢

转载自blog.csdn.net/h2604396739/article/details/84330280