summaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml
blob: ff045512b4c79db098aa53409d36c38a3cbf87f5 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?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="org.onap.usecaseui.intentanalysis.mapper.ContextMapper">


    <insert id="insertContextList">
        insert into context(context_id, context_name, parent_id)
        values
        <foreach collection="contextList" index="index" item="item" separator=",">
            (#{item.contextId}, #{item.contextName}, #{parentId})
        </foreach>
    </insert>

    <select id="selectContextList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Context">
        select context_id contextId, context_name contextName
        from context
        where parent_id = #{parentId}
    </select>

    <select id="selectContext" resultType="org.onap.usecaseui.intentanalysis.bean.models.Context">
        select context_id contextId, context_name contextName
        from context
        where context_id = #{contextId}
    </select>

    <insert id="insertContext">
        insert into context(context_id, context_name, parent_id)
        values
            (#{context.contextId}, #{context.contextName}, #{parentId})
    </insert>

    <update id="updateContext">
        update context
        <trim prefix="set" suffixOverrides=",">
            <if test="context.contextName != null">context_name = #{context.contextName},</if>
        </trim>
        where context_id = #{context.contextId}
    </update>

    <delete id="deleteContext">
        DELETE FROM context WHERE context_id = #{context.contextId}
    </delete>

    <delete id="deleteContextList">
        DELETE FROM context WHERE parent_id = #{parentId}
    </delete>
</mapper>