`

Mybatis之批量插入

阅读更多
    <insert id="insertEmpSelectiveBatch" parameterType="java.util.List" >
	   begin
	   <foreach collection="list" item="item" index="index" separator=";" >
	     insert into EMP
	     <trim prefix="(" suffix=")" suffixOverrides="," >
	      <if test="item.empno != null">
	        EMPNO,
	      </if>
	      <if test="item.ename != null">
	        ENAME,
	      </if>
	      <if test="item.job != null">
	        JOB,
	      </if>
	      <if test="item.mgr != null">
	        MGR,
	      </if>
	      <if test="item.hiredate != null">
	        HIREDATE,
	      </if>
	      <if test="item.sal != null">
	        SAL,
	      </if>
	      <if test="item.comm != null">
	        COMM,
	      </if>
	      <if test="item.deptno != null">
	        DEPTNO,
	      </if>
	     </trim>
	     <trim prefix="values (" suffix=")" suffixOverrides="," >
	      <if test="item.empno != null">
	        #{item.empno,jdbcType=DECIMAL},
	      </if>
	      <if test="item.ename != null">
	        #{item.ename,jdbcType=VARCHAR},
	      </if>
	      <if test="item.job != null">
	        #{item.job,jdbcType=VARCHAR},
	      </if>
	      <if test="item.mgr != null">
	        #{item.mgr,jdbcType=DECIMAL},
	      </if>
	      <if test="item.hiredate != null">
	        #{item.hiredate,jdbcType=TIMESTAMP},
	      </if>
	      <if test="item.sal != null">
	        #{item.sal,jdbcType=DECIMAL},
	      </if>
	      <if test="item.comm != null">
	        #{item.comm,jdbcType=DECIMAL},
	      </if>
	      <if test="item.deptno != null">
	        #{item.deptno,jdbcType=DECIMAL},
	      </if>
	     </trim>
	 </foreach>
	 ;commit;end;
	</insert>
分享到:
评论
1 楼 aa00aa00 2014-10-29  
你的这个是基于mysql的把?

相关推荐

Global site tag (gtag.js) - Google Analytics