批量插入忽略错误
<insert id="insertFaceDeviceIgnore" parameterType="java.util.List">
insert IGNORE face_device (ID, APP_ID, USER_GUID,
DEVICE_KEY, FACE_GUID, STATE,
MSG, PERSON_GUID)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id,jdbcType=INTEGER}, #{item.appId,jdbcType=VARCHAR}, #{item.userGuid,jdbcType=VARCHAR},
#{item.deviceKey,jdbcType=VARCHAR}, #{item.faceGuid,jdbcType=VARCHAR}, #{item.state,jdbcType=BIT},
#{item.msg,jdbcType=VARCHAR}, #{item.personGuid,jdbcType=VARCHAR})
</foreach>
</insert>
批量查找主键冲突的主键值,list返回
<select id="selectFaceDevicePKsExist" parameterType="java.util.List" resultType="java.lang.Integer">
select
ID
from face_device
where 1=1
AND (
<foreach collection="list" item="item" index="index" separator=" or ">
ID = #{item.id,jdbcType=INTEGER}
</foreach>
)
</select>
网友评论