mybatis list--foreach 循环

1.对象循环插入(List<ActLabelGroupRel>)
  实体类ActLabelGroupRel:

private String labelGroupId ;
private String labelId ;
private String labelName ;

  dao层代码:

void insertActLabelGroupRel(@Param("listData") List<ActLabelGroupRel> listData);

  xml文件代码:

 <insert id="insertActLabelGroupRel">
        insert into act_label_group_rel
        values
        <foreach collection="listData" item="param"  separator="," close=";">
            (#{param.labelGroupId}, #{param.labelId}, #{param.labelName})
        </foreach>
    </insert>

 

posted @ 2023-03-06 11:14  krt-wanyi  阅读(378)  评论(0编辑  收藏  举报