170829. mybatis using batch update in Oracle and MyBatis

Source: Internet
Author: User

1, the database connection must be configured: &allowmultiqueries=true (remember must add this attribute, otherwise there will be problems, remember!) remember! )
My configuration is as follows: Jdbc:mysql://127.0.0.1:3306/test?useunicode=true&characterencoding=utf-8& Allowmultiqueries=true
2, Batch modification and add Judgment condition (Modify field optional)
<!--batch Update-<update id= "Updatematchs" parametertype= "java.util.List" > <foreach collection= "MATC HS "item=" item "index=" index "open=" "close=" "separator="; " >Update T_match<set> <iftest= "Item.title!=null" >TITLE= #{item.title,jdbctype=VARCHAR},</if> <iftest= "Item.homescore!=null" >Home_score= #{item.homescore,jdbctype=INTEGER},</if> <iftest= "Item.visitscore!=null" >Vistt_score= #{item.visitscore,jdbctype=INTEGER},</if> <iftest= "Item.livesource!=null" >Live_source= #{item.livesource,jdbctype=VARCHAR},</if> <iftest= "Item.liveurl!=null" >Live_url= #{item.liveurl,jdbctype=VARCHAR},</if> <iftest= "Item.ishotmatch!=null" >Is_hot_match= #{item.ishotmatch,jdbctype=VARCHAR}</if> </set>where home_team_id= #{item.hometeamid,jdbctype=VARCHAR} and visit_team_id= #{item.visitteamid,jdbctype=VARCHAR} and Match_time= #{item.matchtime,jdbctype=BIGINT}</foreach> </update>
3. Java interface
  /**      * Batch revision schedule     *      @param  matchs     @throws  daoexception      *    /void Updatematchs (@Param (value = "Matchs") list<matchbasic> matchs);
Second, MyBatis the method of batch updating batch update (Oracle database)

1, Batch modification and add Judgment condition (Modify field optional)

<update id= "batchupdatesplitsinglepickcurrency" parametertype= "java.util.List" > <foreach collection= "List "Item=" item "index=" Index "open= "Begin" close= "; end;" Separator= ";">UPDATE zc_tr_multi_order_currency<set> <ifTest= "Item.syscordercode! = null" >Sys_corder_code= #{item.syscordercode,jdbctype=VARCHAR},</if> <ifTest= "Item.syspordercode! = null" >Sys_porder_code= #{item.syspordercode,jdbctype=VARCHAR},</if> <ifTest= "Item.bizpordercode! = null" >Biz_porder_code= #{item.bizpordercode,jdbctype=VARCHAR},</if> <ifTest= "Item.originalordercode! = null" >Original_order_code= #{item.originalordercode,jdbctype=VARCHAR},</if> <ifTest= "Item.splituserid! = null" >split_user_id= #{item.splituserid,jdbctype=VARCHAR},</if> <ifTest= "Item.createdate! = null" >create_date=#{item.createdate},</if> <ifTest= "Item.updatedate! = null" >update_date=#{item.updatedate},</if> </set>where ID= #{item.id,jdbctype=VARCHAR}</foreach> </update>

2. Java interface

/**
* @Desc: batch Update bulk Quantum Order Details * @Author: ZRP * @Date: 2018/1/26 15:24 * * int throws Exception;
PS: Be sure to pay attention to the text of the Red place, today is my mistake, it took me 20 minutes ...

170829. mybatis using batch update in Oracle and MyBatis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.