批量删除和批量修改(参数使用list)

批量添加:

<insert id="batchInsert" parameterType="List">
insert into finance_loan_info_share_balances_detail
(
contnum,
period_name,
before_amount,
done_fen_qi_amount,
remained_fen_qi_amount,
period_fen_qi_amount,
period_fen_qi_shu,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
create_date,
last_update_date
)
values
<foreach collection="list" item="temp" separator=",">
(#{temp.contnum},#{temp.period_name},#{temp.before_amount},#{temp.done_fen_qi_amount},
#{temp.remained_fen_qi_amount},#{temp.period_fen_qi_amount},#{temp.period_fen_qi_shu},
#{temp.attribute1},#{temp.attribute2},#{temp.attribute3},#{temp.attribute4},#{temp.attribute5},
#{temp.attribute6},#{temp.attribute7},#{temp.create_date},NOW())
</foreach>
</insert>


批量修改:
<insert id="updateBatch" parameterType="list">
insert into
finance_loan_info_share_balances(id,contnum,done_fen_qi_amount,remained_fen_qi_shu,remained_fen_qi_amount,period_name,
contract_status,last_update_date,fen_qi_amount)
values
<foreach collection="list" item="temp" separator=",">
(#{temp.id},#{temp.contnum},#{temp.done_fen_qi_amount},#{temp.remained_fen_qi_shu},
#{temp.remained_fen_qi_amount},#{temp.period_name},#{temp.contract_status},NOW(),#{temp.fen_qi_amount})
</foreach>
on duplicate key update
done_fen_qi_amount=values(done_fen_qi_amount),
remained_fen_qi_shu = values(remained_fen_qi_shu),
remained_fen_qi_amount = values(remained_fen_qi_amount),
period_name = values(period_name),
fen_qi_amount= values(fen_qi_amount),
contract_status = values(contract_status),
last_update_date = values(last_update_date)
</insert>
原文地址:https://www.cnblogs.com/Dream--/p/8477801.html