设置mysql 索引
在mybatis.xml里面使用 ON DUPLICATE KEY UPDATE
<insert id="insertZfCompanyList">
insert into zf_company (
com_id,
zf_user_id,
com_name,
register_sta,
com_people,
com_capital,
esta_time,
roval_time,
com_pro,
com_city,
com_area,
com_phone,
com_phone2,
com_email,
com_email2,
com_code,
com_id_code,
com_register,
com_organ,
insured_no,
com_type,
com_trade,
once_name,
web_site,
com_address,
report_address,
com_scope,
com_stutas,
create_by,
create_time,
update_by,
update_time,
expire_time,
is_opening,
remark,
creation
) values
<foreach collection="list" item="item" separator=",">
(
#{item.comId},
#{item.zfUserId},
#{item.comName},
#{item.registerSta},
#{item.comPeople},
#{item.comCapital},
#{item.estaTime},
#{item.rovalTime},
#{item.comPro},
#{item.comCity},
#{item.comArea},
#{item.comPhone},
#{item.comPhone2},
#{item.comEmail},
#{item.comEmail2},
#{item.comCode},
#{item.comIdCode},
#{item.comRegister},
#{item.comOrgan},
#{item.insuredNo},
#{item.comType},
#{item.comTrade},
#{item.onceName},
#{item.webSite},
#{item.comAddress},
#{item.reportAddress},
#{item.comScope},
#{item.comStutas},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime},
#{item.expireTime},
#{item.isOpening},
#{item.remark},
#{item.creation}
)
</foreach>
ON DUPLICATE KEY UPDATE
register_sta = VALUES(register_sta),
com_people = VALUES(com_people),
com_capital = VALUES(com_capital),
esta_time = VALUES(esta_time),
roval_time = VALUES(roval_time),
com_pro = VALUES(com_pro),
com_city = VALUES(com_city),
com_area = VALUES(com_area),
com_phone = VALUES(com_phone),
com_phone2 = VALUES(com_phone2),
com_email = VALUES(com_email),
com_email2 = VALUES(com_email2),
com_code = VALUES(com_code),
com_id_code = VALUES(com_id_code),
com_register = VALUES(com_register),
com_organ = VALUES(com_organ),
insured_no = VALUES(insured_no) ,
com_type = VALUES(com_type) ,
com_trade = VALUES(com_trade) ,
once_name = VALUES(once_name) ,
web_site = VALUES(web_site) ,
com_address = VALUES(com_address) ,
report_address= VALUES(report_address) ,
com_scope = VALUES(com_scope) ,
com_stutas = VALUES(com_stutas) ,
create_by = VALUES(create_by) ,
create_time = VALUES(create_time) ,
update_by = VALUES(update_by) ,
update_time = VALUES(update_time) ,
expire_time = VALUES(expire_time) ,
is_opening = VALUES(is_opening) ,
remark = VALUES(remark) ,
creation= VALUES(creation)
</insert>
在批量插入的时候 如果有重复的索引会自动更新