首页 > 代码库 > Mybatis 针对oracle的批量插入

Mybatis 针对oracle的批量插入

xml文件参数对象:

1 public class Columns{2     private String basedate_code;3     private String tableName;4     private String codeDescribeindex;5     private String codeInfoindex;6     private String codePymindex;7     private List<Info> infos;

Dao层方法:

public void bulkInsert(Columns columns);

xml文件配置:

 1 <insert id="bulkInsert" parameterType="Columns"> 2         insert into manager_basedata_info (app_code,basedata_code,item_code,item_name,item_pym,updatetime) 3         <foreach collection="infos" item="item"  index="index"  separator="UNION"> 4             select  5               ‘pc‘, 6                #{basedate_code,jdbcType=VARCHAR}, 7                #{item.item_code,jdbcType=VARCHAR}, 8                #{item.item_name,jdbcType=VARCHAR}, 9                #{item.item_pym,jdbcType=VARCHAR},10                sysdate 11                from dual12         </foreach>13     </insert>