zoukankan      html  css  js  c++  java
  • MyBatis常用批量方法

    <!-- 批量添加派车单子表数据 -->
    	  <insert id="addBatch" parameterType="java.util.List" >
    			insert into hylm_shipment_item
    			(
    				ship_number,
    				order_number,
    				pre_number,
    				goods_id,
    				real_num,
    				real_weight,
    				real_cubage,
    				cost,
    				creater,
    				createDate,
    				finalOperator,
    				operatTime,
    				pId,
    				uId,
    				orgId,
    				roleId
    			)
    			values
    			<foreach collection="list" item="item" index="index" separator=",">
    				 (
    					 #{item.shipnumber,jdbcType=VARCHAR},
    					 #{item.ordernumber,jdbcType=VARCHAR},
    					 #{item.prenumber,jdbcType=VARCHAR},
    					 #{item.goodsid,jdbcType=FLOAT},
    					 #{item.realnum,jdbcType=VARCHAR},
    					 #{item.realweight,jdbcType=VARCHAR},
    					 #{item.realcubage,jdbcType=VARCHAR},
    					 #{item.cost,jdbcType=VARCHAR},
    					 #{item.creater,jdbcType=VARCHAR},
    					 #{item.createDate,jdbcType=VARCHAR},
    					 #{item.finalOperator,jdbcType=VARCHAR},
    					 #{item.operatTime,jdbcType=VARCHAR},
    					 #{item.pId,jdbcType=VARCHAR},
    					 #{item.uId,jdbcType=VARCHAR},
    					 #{item.orgId,jdbcType=VARCHAR},
    					 #{item.roleId,jdbcType=VARCHAR}
    				 )
    			</foreach>
    	  </insert>
    	  
    	  <!-- 批量删除中转地数据 -->
    	  <delete id = "deleteBatch" parameterType = "java.util.List">  
    		    <![CDATA[  
    		       delete from hylm_shipment_item where id in  
    		    ]]>  
    		    <foreach collection="list" item="model" open="(" separator="," close=")">
    		    	#{model.id}  
    		    </foreach>  
    	  </delete> 
    	  
    	  <!-- 批量更新派车单子表数据 -->
    	  <update id="updateBatch" parameterType="java.util.List">
    			<foreach collection="list" item="item" index="index" separator=";">
    				update hylm_shipment_item  
    	             <trim prefix="set" prefixOverrides=","> 
    					<if test="item.id != null and item.id != ''">
    					    ,id = #{item.id}
    					</if>
    					<if test="item.shipnumber != null and item.shipnumber != ''">
    					    ,ship_number = #{item.shipnumber}
    					</if>
    					<if test="item.ordernumber != null and item.ordernumber != ''">
    					    ,order_number = #{item.ordernumber}
    					</if>
    					<if test="item.prenumber != null and item.prenumber != ''">
    					    ,pre_number = #{item.prenumber}
    					</if>
    					<if test="item.goodsid != null and item.goodsid != ''">
    					    ,goods_id = #{item.goodsid}
    					</if>
    					<if test="item.realnum != null and item.realnum != ''">
    					    ,real_num = #{item.realnum}
    					</if>
    					<if test="item.realweight != null and item.realweight != ''">
    					    ,real_weight = #{item.realweight}
    					</if>
    					<if test="item.realcubage != null and item.realcubage != ''">
    					    ,real_cubage = #{item.realcubage}
    					</if>
    					<if test="item.cost != null and item.cost != ''">
    					    ,cost = #{item.cost}
    					</if>
    					<if test="item.creater != null and item.creater != ''">
    					    ,creater = #{item.creater}
    					</if>
    					<if test="item.createDate != null and item.createDate != ''">
    					    ,createDate = #{item.createDate}
    					</if>
    					<if test="item.finalOperator != null and item.finalOperator != ''">
    					    ,finalOperator = #{item.finalOperator}
    					</if>
    					<if test="item.operatTime != null and item.operatTime != ''">
    					    ,operatTime = #{item.operatTime}
    					</if>
    					<if test="item.pId != null">
                           ,pId = #{item.pId,jdbcType=VARCHAR}
                       </if>
                       <if test="item.uId != null">
                           ,uId = #{item.uId,jdbcType=VARCHAR}
                       </if>
                       <if test="item.orgId != null">
                           ,orgId = #{item.orgId,jdbcType=VARCHAR}
                       </if>
                       <if test="item.roleId != null">
                           ,roleId = #{item.roleId,jdbcType=VARCHAR}
                       </if>
    				</trim>
    	             where 1 = 1
    	             <if test="item.id != null and item.id != ''">
    					    and id = #{item.id}
    					</if>
    					<if test="item.ordernumber != null and item.ordernumber != ''">
    					    and order_number = #{item.ordernumber}
    					</if>
    					<if test="item.uId != null and item.uId != ''">
    					    and uId = #{item.uId}
    					</if>
    			</foreach>
    	  </update>
    
  • 相关阅读:
    进程 线程 协程之间的区别与联系
    http协议基础 5.关于http请求响应报文的总结
    http协议基础 4. http请求报文格式
    http协议基础 3.URI URL 与URN之间的联系与区别。
    python面试题----持续更新中
    python之禅
    Django 2.0 报错解决方案----持续更新中
    4
    3
    2
  • 原文地址:https://www.cnblogs.com/deepbreath/p/5015112.html
Copyright © 2011-2022 走看看