标签:match value char rom flag reac ati user 对象
<insert id="batchUpdatePBWUserInfo" parameterType="java.util.List"> MERGE INTO S_PBW_USER t USING ( <foreach collection="list" item="item" index="index" separator="union" > SELECT #{item.userId,jdbcType=VARCHAR} USERID, #{item.userName,jdbcType=VARCHAR} USERNAME, #{item.userType,jdbcType=VARCHAR} USERTYPE, #{item.mobile,jdbcType=VARCHAR} MOBILE, #{item.code,jdbcType=VARCHAR} USECODE, #{item.companyName,jdbcType=VARCHAR} COMPANYNAME, SYSDATE CREATE_TIME FROM DUAL </foreach>) t1 ON (t.USER_ID = t1.USERID ) WHEN MATCHED THEN UPDATE SET t.update_time = t1.CREATE_TIME WHEN NOT MATCHED THEN INSERT(ID, USER_ID, USER_NAME, MOBILE, CODE, COMPAY_NAME, DEL_FLAG,CREATE_TIME) VALUES (t1.USERID, t1.USERID, t1.USERNAME, t1.MOBILE, t1.USECODE, t1.COMPANYNAME, 0,t1.CREATE_TIME) </insert>
总则:使用merge,存在就更新,不存在就插入
其中,需要注意:1.其中list中放的是个实体对象 list = new ArrayList<PBWUserInfo>();
2.一次最好不要插入太多(本人是每次200,休眠一秒,因为是在循环里面异步处理的),否则会出现一些其他的错误。用代码控制一次插入的条数
标签:match value char rom flag reac ati user 对象
原文地址:https://www.cnblogs.com/lazyInsects/p/9456498.html