<?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.ibizlab.core.sample.mapper.IBIZSample0016Mapper">

    <!--该方法用于重写mybatis中selectById方法，以实现查询逻辑属性-->
	<select id="selectById"  resultMap="IBIZSample0016ResultMap" databaseId="dm">
        <![CDATA[select * from v_ibizsample0016 t1     where  ibizsample0016id=#{id}]]>
    </select>
	<select id="selectById"  resultMap="IBIZSample0016ResultMap" databaseId="hana">
        <![CDATA[select * from v_ibizsample0016 t1     where  ibizsample0016id=#{id}]]>
    </select>
	<select id="selectById"  resultMap="IBIZSample0016ResultMap" databaseId="mysql">
        <![CDATA[select * from v_ibizsample0016 t1     where  ibizsample0016id=#{id}]]>
    </select>
	<select id="selectById"  resultMap="IBIZSample0016ResultMap" databaseId="postgresql">
        <![CDATA[select * from v_ibizsample0016 t1     where  ibizsample0016id=#{id}]]>
    </select>
	<select id="selectById"  resultMap="IBIZSample0016ResultMap" databaseId="sqlserver">
        <![CDATA[select * from v_ibizsample0016 t1     where  ibizsample0016id=#{id}]]>
    </select>

    <!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
    <resultMap id="IBIZSample0016ResultMap" type="cn.ibizlab.core.sample.domain.IBIZSample0016" autoMapping="true">
		<id property="ibizsample0016id" column="ibizsample0016id" /><!--主键字段映射-->
		<result property="ibizsample0015id" column="ibizsample0015id" />
		<result property="ibizsample0014id" column="ibizsample0014id" />
            
		
		<!--通过mybatis自动注入关系属性[主实体]，fetchType="lazy"为懒加载配置 -->
		<association property="ibizsample0014" javaType="cn.ibizlab.core.sample.domain.IBIZSample0014" column="ibizsample0014id" select="cn.ibizlab.core.sample.mapper.IBIZSample0014Mapper.selectById" fetchType="lazy"></association>
		<!--通过mybatis自动注入关系属性[主实体]，fetchType="lazy"为懒加载配置 -->
		<association property="ibizsample0015" javaType="cn.ibizlab.core.sample.domain.IBIZSample0015" column="ibizsample0015id" select="cn.ibizlab.core.sample.mapper.IBIZSample0015Mapper.selectById" fetchType="lazy"></association>
    </resultMap>

	<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_IBIZSAMPLE0016_IBIZSAMPLE0014_IBIZSAMPLE0014ID] -->
	 <select id="selectByIbizsample0014id" resultMap="IBIZSample0016ResultMap">
         select t1.* from (
                <include refid="Default" />
			 ) t1
			 where  ibizsample0014id=#{ibizsample0014id}
     </select>
	<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_IBIZSAMPLE0016_IBIZSAMPLE0015_IBIZSAMPLE0015ID] -->
	 <select id="selectByIbizsample0015id" resultMap="IBIZSample0016ResultMap">
         select t1.* from (
                <include refid="Default" />
			 ) t1
			 where  ibizsample0015id=#{ibizsample0015id}
     </select>

    <!--数据集合[Default]-->
	 <select id="searchDefault"  parameterType="cn.ibizlab.core.sample.filter.IBIZSample0016SearchContext"  resultMap="IBIZSample0016ResultMap">
         select t1.* from (
                <include refid="Default" />
         )t1
         <where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
         <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
     </select>

    <!--数据查询[Default]-->
    <sql id="Default" databaseId="dm">
		<![CDATA[ SELECT t1.CREATEDATE, t1.CREATEMAN, t1.IBIZSAMPLE0014ID, t21.IBIZSAMPLE0014NAME, t1.IBIZSAMPLE0015ID, t11.IBIZSAMPLE0015NAME, t1.IBIZSAMPLE0016ID, t1.IBIZSAMPLE0016NAME, t1.UPDATEDATE, t1.UPDATEMAN FROM T_IBIZSAMPLE0016 t1  LEFT JOIN T_IBIZSAMPLE0015 t11 ON t1.IBIZSAMPLE0015ID = t11.IBIZSAMPLE0015ID  LEFT JOIN T_IBIZSAMPLE0014 t21 ON t1.IBIZSAMPLE0014ID = t21.IBIZSAMPLE0014ID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="hana">
		<![CDATA[ SELECT t1.\"CREATEDATE\", t1.\"CREATEMAN\", t1.\"IBIZSAMPLE0014ID\", t21.\"IBIZSAMPLE0014NAME\", t1.\"IBIZSAMPLE0015ID\", t11.\"IBIZSAMPLE0015NAME\", t1.\"IBIZSAMPLE0016ID\", t1.\"IBIZSAMPLE0016NAME\", t1.\"UPDATEDATE\", t1.\"UPDATEMAN\" FROM \"T_IBIZSAMPLE0016\" t1  LEFT JOIN T_IBIZSAMPLE0015 t11 ON t1.IBIZSAMPLE0015ID = t11.IBIZSAMPLE0015ID  LEFT JOIN T_IBIZSAMPLE0014 t21 ON t1.IBIZSAMPLE0014ID = t21.IBIZSAMPLE0014ID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="mysql">
		<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`IBIZSAMPLE0014ID`, t21.`IBIZSAMPLE0014NAME`, t1.`IBIZSAMPLE0015ID`, t11.`IBIZSAMPLE0015NAME`, t1.`IBIZSAMPLE0016ID`, t1.`IBIZSAMPLE0016NAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_IBIZSAMPLE0016` t1  LEFT JOIN T_IBIZSAMPLE0015 t11 ON t1.IBIZSAMPLE0015ID = t11.IBIZSAMPLE0015ID  LEFT JOIN T_IBIZSAMPLE0014 t21 ON t1.IBIZSAMPLE0014ID = t21.IBIZSAMPLE0014ID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="postgresql">
		<![CDATA[ SELECT t1.CREATEDATE, t1.CREATEMAN, t1.IBIZSAMPLE0014ID, t21.IBIZSAMPLE0014NAME, t1.IBIZSAMPLE0015ID, t11.IBIZSAMPLE0015NAME, t1.IBIZSAMPLE0016ID, t1.IBIZSAMPLE0016NAME, t1.UPDATEDATE, t1.UPDATEMAN FROM T_IBIZSAMPLE0016 t1  LEFT JOIN T_IBIZSAMPLE0015 t11 ON t1.IBIZSAMPLE0015ID = t11.IBIZSAMPLE0015ID  LEFT JOIN T_IBIZSAMPLE0014 t21 ON t1.IBIZSAMPLE0014ID = t21.IBIZSAMPLE0014ID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="sqlserver">
		<![CDATA[ SELECT t1.[CREATEDATE], t1.[CREATEMAN], t1.[IBIZSAMPLE0014ID], t21.[IBIZSAMPLE0014NAME], t1.[IBIZSAMPLE0015ID], t11.[IBIZSAMPLE0015NAME], t1.[IBIZSAMPLE0016ID], t1.[IBIZSAMPLE0016NAME], t1.[UPDATEDATE], t1.[UPDATEMAN] FROM [T_IBIZSAMPLE0016] t1  LEFT JOIN T_IBIZSAMPLE0015 t11 ON t1.IBIZSAMPLE0015ID = t11.IBIZSAMPLE0015ID  LEFT JOIN T_IBIZSAMPLE0014 t21 ON t1.IBIZSAMPLE0014ID = t21.IBIZSAMPLE0014ID  
			]]>
    </sql>
</mapper>

