首页 > 数据库技术 > 详细

mybatis oracle批量插入数据

时间:2021-03-01 18:43:11      阅读:23      评论:0      收藏:0      [点我收藏+]

 

方式一

<insert id="addBatch" parameterType="java.util.List">  
    BEGIN  
    <foreach collection="list" item="item" index="index" separator="">  
        insert into test  
        (userid,username createdate)  
        VALUES  
        (  
        #{item.userId,jdbcType=INTEGER},
        #{item.username,jdbcType=VARCHAR},#{item.createDate,jdbcType=DATE});  
    </foreach>  
    COMMIT;  
    END;  
</insert>  

 

方式二

<insert id="addBatch"  parameterType="java.util.List">  
    INSERT INTO test (userid,username createdate 
    )  
    <foreach open="("  close=")" collection="list" item="item" index="index" separator="union all" >  
        select #{item.userId,jdbcType=INTEGER},#{item.username,jdbcType=VARCHAR},#{item.createDate,jdbcType=DATE}   
        from dual  
    </foreach>  
</insert> 

 

 

方式三

使用mybatisplus自带的批量插入方法

IService.java
  /**
* 插入(批量) * * @param entityList 实体对象集合 * @param batchSize 插入批次数量 */ boolean saveBatch(Collection<T> entityList, int batchSize);

 

 

 

mybatis oracle批量插入数据

原文:https://www.cnblogs.com/kiko2014551511/p/14464997.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!