<?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="ru.nbch.indicsearchservice.repository.bank.SettingsMapper">
    <resultMap id="settingsResultMap" type="ru.nbch.indicsearchservice.model.Settings">
        <id column="ID" property="id"/>
        <result column="VERSION" property="version"/>
        <result column="NAME" property="name"/>
        <result column="VALUE" property="value"/>
    </resultMap>

    <sql id="baseSelect">
        SELECT ID,
               VERSION,
               NAME,
               "VALUE"
        FROM SETTINGS
    </sql>

    <select id="findByName" resultMap="settingsResultMap">
        <include refid="baseSelect"/>
        where NAME = #{name}
        WITH UR
    </select>

    <select id="findAllByNames" resultMap="settingsResultMap">
        <include refid="baseSelect"/>
        WHERE NAME IN
        <foreach item='name' collection='names' open='(' separator=',' close=')'>#{name}</foreach>
    </select>

    <select id="findAll" resultMap="settingsResultMap">
        <include refid="baseSelect"/>
        WITH UR
    </select>
</mapper>