zoukankan      html  css  js  c++  java
  • Mybatis 循环 foreach, 批量操作

    mapper.java: 

       int modifySortOfGoods(@Param("idlist") List<String> goodsIds, @Param("goodsSortId")Long goodsSortId);

    mapper.xml

    <update id="modifySortOfGoods" parameterType="java.util.List">
       UPDATE goods SET goods_sort_id = #{goodsSortId}
       WHERE id in
        <foreach item="goodsId" collection="idlist" separator="," open="(" close=")" index="">
            #{goodsId}
        </foreach>
    </update>

    result:

    UPDATE goods SET goods_sort_id = 4
     WHERE id in ( '1' , '2' );

    foreanch 标签中的 collection的值要对应mapper.java中的@param("") 里面的值

  • 相关阅读:
    echo
    shell
    grub
    find
    脚本案例
    dd if= of= MBR
    cat <<EOF> file
    fieldset——一个不常用的HTML标签
    闪烁图片
    跑马灯效果
  • 原文地址:https://www.cnblogs.com/jxlsblog/p/10906424.html
Copyright © 2011-2022 走看看