首先以下这种是错误的 mybatis 映射并不能识别符号; 所以pass
<update id="updateBatch">
<foreach collection="list" separator=";" item="representativesAndPrincipalPersonnel">
update representatives_and_principal_personnel set
idcard_number = #{representativesAndPrincipalPersonnel.idcard_number,jdbcType=VARCHAR}
where id = #{representativesAndPrincipalPersonnel.id,jdbcType=INTEGER}
</foreach>
</update>
这种 使用when then 的方法才能使用
<update id="updateBatch" parameterType="list">
update representatives_and_principal_personnel
<trim prefix="set" suffixOverrides=",">
<trim prefix="examine_and_approve_id =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.examine_and_approve_id!=null">
when id=#{i.id} then #{i.examine_and_approve_id}
</if>
</foreach>
</trim>
<trim prefix="idcard_number =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.idcard_number!=null">
when id=#{i.id} then #{i.idcard_number}
</if>
</foreach>
</trim>
<trim prefix="name =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.name!=null">
when id=#{i.id} then #{i.name}
</if>
</foreach>
</trim>
<trim prefix="sex =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.sex!=null">
when id=#{i.id} then #{i.sex}
</if>
</foreach>
</trim>
<trim prefix="duty =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.duty!=null">
when id=#{i.id} then #{i.duty}
</if>
</foreach>
</trim>
<trim prefix="rankv =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.rankv!=null">
when id=#{i.id} then #{i.rankv}
</if>
</foreach>
</trim>
<trim prefix="birth =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.birth!=null">
when id=#{i.id} then #{i.birth}
</if>
</foreach>
</trim>
<trim prefix="standard_culture =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.standard_culture!=null">
when id=#{i.id} then #{i.standard_culture}
</if>
</foreach>
</trim>
<trim prefix="workspace =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.workspace!=null">
when id=#{i.id} then #{i.workspace}
</if>
</foreach>
</trim>
<trim prefix="state =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.state!=null">
when id=#{i.id} then #{i.state}
</if>
</foreach>
</trim>
<trim prefix="phone =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.phone!=null">
when id=#{i.id} then #{i.phone}
</if>
</foreach>
</trim>
<trim prefix="have_bad_record =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.have_bad_record!=null">
when id=#{i.id} then #{i.have_bad_record}
</if>
</foreach>
</trim>
<trim prefix="amount_of_contribution =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.amount_of_contribution!=null">
when id=#{i.id} then #{i.amount_of_contribution}
</if>
</foreach>
</trim>
</trim>
where
<foreach collection="list" separator="or" item="representativesAndPrincipalPersonnel" index="index">
id=#{representativesAndPrincipalPersonnel.id}
</foreach>
</update>
2361

被折叠的 条评论
为什么被折叠?



