<?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="cn.fateverse.query.mapper.TableRelationalMappingMapper">

    <insert id="batchInsert">
        insert into table_relational_mapping (main_id, child_id, main_key, child_key, type) VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.mainId},#{item.childId},#{item.mainKey},#{item.childKey},#{item.type})
        </foreach>
    </insert>

    <select id="selectByMainId"
            resultType="cn.fateverse.query.entity.TableRelationalMapping">
        select main_id, child_id, main_key, child_key, type
        from table_relational_mapping where main_id = #{mainId}
    </select>

    <select id="selectByMainIds" resultType="cn.fateverse.query.entity.TableRelationalMapping">
        select main_id, child_id, main_key, child_key, type from table_relational_mapping
        where main_id in
        <foreach collection="list" open="(" separator="," close=")" item="mainId">
            #{mainId}
        </foreach>
    </select>

    <delete id="deleteByMainId">
        delete from table_relational_mapping where main_id = #{mainId}
    </delete>

</mapper>