mybatis批量插入
mybatis批量插入
注意类型就是list,collection可以谁便取为list(只有一个参数的时候)
int insertBatch(List<TBUserInfoDO> record);
<insert id="insertBatch" parameterType="java.util.List" >
insert into tb_userinfo (ID, MOBILE, REG_TIME,
IDENTITY_NO, INVITATION_CODE, INVITER_INVITATION_CODE,
UTM_SOURCE, NAME, TENDER_STATUS,
CITY, ORDER_TYPE, RE_ID,
INVIT_MOBILE, EMP_ID, ISASSIGN,
USERID, SEX, CHANNEL_CODE
)
values
<foreach collection ="list" item="user" separator =",">
(#{user.id}, #{user.mobile}, #{user.regTime}, #{user.identityNo}, #{user.invitationCode}, #{user.inviterInvitationCode}
, #{user.utmSource}, #{user.name}, #{user.tenderStatus}, #{user.city}, #{user.orderType}, #{user.reId}
, #{user.invitMobile}, #{user.empId}, #{user.isassign},#{user.userid}, #{user.sex}, #{user.channelCode})
</foreach >
</insert>
上一篇: davinci常见问题