<?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.xisc.pm.infra.mapper.PmSubCheckChmMapper">


    <sql id = "BaseSql">
    PSCC.ID,
    PSCC.PONO,
    PSCC.ORDER_NO,
    PSCC.CHM_RESULT,
    PSCC.OLD_RESULT,
    PSCC.TENANT_ID,
    PSCC.ATTRIBUTE1,
    PSCC.ATTRIBUTE2,
    PSCC.ATTRIBUTE3,
    PSCC.ATTRIBUTE4,
    PSCC.ATTRIBUTE5,
    PSCC.creation_date,    PSCC.created_by,    PSCC.last_updated_by,    PSCC.last_update_date,    PSCC.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.entity.PmSubCheckChm">
        select
        <include refid = "BaseSql"/>
        from PM_SUB_CHECK_CHM PSCC
        <where>
            <if test="id !=null">
                and PSCC.ID = #{id,jdbcType = INTEGER}
            </if>
            <if test="pono !=null">
                and PSCC.PONO = #{pono,jdbcType = VARCHAR}
            </if>
            <if test="orderNo !=null">
                and PSCC.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
            </if>
            <if test="chmResult !=null">
                and PSCC.CHM_RESULT = #{chmResult,jdbcType = VARCHAR}
            </if>
            <if test="oldResult !=null">
                and PSCC.OLD_RESULT = #{oldResult,jdbcType = VARCHAR}
            </if>
            <if test="tenantId !=null">
                and PSCC.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and PSCC.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and PSCC.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and PSCC.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and PSCC.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and PSCC.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
        </where>
    </select>

    <select id = "selectByPonoAndOrderNo" resultType = "com.xisc.pm.domain.entity.PmSubCheckChm">
        select
        <include refid = "BaseSql"/>
        from PM_SUB_CHECK_CHM PSCC
        where PSCC.PONO = #{pono,jdbcType = VARCHAR}
        and PSCC.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
    </select>
</mapper>

