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