fangyuan
2022-11-18 c9d9a680d60722048fec46019b4a7ca36f821c58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ycl.mapper.NewsChannelColumnDao">
 
    <resultMap type="com.ycl.entity.NewsChannelColumn" id="NewsChannelColumnMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="channelId" column="channel_id" jdbcType="INTEGER"/>
        <result property="columnId" column="column_id" jdbcType="INTEGER"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel_column(channel_id, column_id)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.channelId}, #{entity.columnId})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel_column(channel_id, column_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.channelId}, #{entity.columnId})
        </foreach>
        on duplicate key update
         channel_id = values(channel_id) , column_id = values(column_id)     </insert>
 
</mapper>