介绍
- collection:必填,值为要迭代循环的属性名。这个属性值的情况有很多
- item :变量名,值为从迭代对象中取出来的每一个值
- index: 索引的属性名,在集合数组情况下值为当前索引值,当迭代循环的对象时Map类型时,这个值为map的key值
- open: 整个循环内容开头的字符串
- close:整个循环内容结尾的字符串
- separator: 每次循环的分隔符
xml
<insert id="insertCustomersBatch" parameterType="java.util.List"> insert into STOREROOM_REPERTORY(UUID, CUSTOMERSNAME, CUSTOMERSNO, COMMUNITY, REPERTORY_CODE, REPERTORY_AREA, COLOUR, CREATE_DATE, LOT, STATUS, OPERATOR_DATE) <foreach collection="list" item="item" index="index" separator="union all"> ( SELECT #{item.uuid}, #{item.customersname}, #{item.customersno}, #{item.community}, #{item.repertoryCode}, #{item.repertoryArea}, #{item.colour}, #{item.createDate}, #{item.lot}, #{item.status}, #{item.operatorDate} FROM DUAL ) </foreach> </insert>