Mybatis使用经验分享之批量操作 http://jingyan.baidu.com/article/11c17a2c7f376af446e39d21.html

解决方案 »

  1.   

    比如查询中的in条件    <select id="getAllPlayerFabaoFrag" resultType="XXObj">
            SELECT
                *
            FROM
                XXObj
            WHERE
                group_id in
        ]]>
            <foreach item="item" index="index" collection="groupIds"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </select>对应的mapper:
     List<XXObj> getAllPlayerFabaoFrag(@Param("logicalServerNums") List<Integer> groupIds);
      

  2.   

    http://blog.csdn.net/bareheadzzq/article/details/8006131
      

  3.   

    当你传递来的参数,不是map或Bean之类的,而是一个List或数组,你该怎么取里面的数据呢?
    此时,就需要使用foreach来一次循环里面的每个值了。用法如下:
    <foreach item="item"   index="index"   collection="list"    open="(" separator="," close=")">
                #{item}
     </foreach>
      

  4.   

    做多条件、插入等等,都可以用foreach