<?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.IBIZSample0013Mapper">

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

    <!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
    <resultMap id="IBIZSample0013ResultMap" type="cn.ibizlab.core.sample.domain.IBIZSample0013" autoMapping="true">
		<id property="ibizsample0013id" column="ibizsample0013id" /><!--主键字段映射-->
		<result property="ibizuniproductid" column="ibizuniproductid" />
		<result property="ibizsample0012id" column="ibizsample0012id" />
            
		
		<!--通过mybatis自动注入关系属性[主实体]，fetchType="lazy"为懒加载配置 -->
		<association property="ibizsample0012" javaType="cn.ibizlab.core.sample.domain.IBIZSample0012" column="ibizsample0012id" select="cn.ibizlab.core.sample.mapper.IBIZSample0012Mapper.selectById" fetchType="lazy"></association>
		<!--通过mybatis自动注入关系属性[主实体]，fetchType="lazy"为懒加载配置 -->
		<association property="ibizuniproduct" javaType="cn.ibizlab.core.sample.domain.IBIZUNIProduct" column="ibizuniproductid" select="cn.ibizlab.core.sample.mapper.IBIZUNIProductMapper.selectById" fetchType="lazy"></association>
    </resultMap>

	<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_IBIZSAMPLE0013_IBIZSAMPLE0012_IBIZSAMPLE0012ID] -->
	 <select id="selectByIbizsample0012id" resultMap="IBIZSample0013ResultMap">
         select t1.* from (
                <include refid="Default" />
			 ) t1
			 where  ibizsample0012id=#{ibizsample0012id}
     </select>
	<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_IBIZSAMPLE0013_IBIZUNIPRODUCT_IBIZUNIPRODUCTID] -->
	 <select id="selectByIbizuniproductid" resultMap="IBIZSample0013ResultMap">
         select t1.* from (
                <include refid="Default" />
			 ) t1
			 where  ibizuniproductid=#{ibizuniproductid}
     </select>

    <!--数据集合[Default]-->
	 <select id="searchDefault"  parameterType="cn.ibizlab.core.sample.filter.IBIZSample0013SearchContext"  resultMap="IBIZSample0013ResultMap">
         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.QUANTITY*t21.UNITPRICE AS AMOUNT, t1.CREATEDATE, t1.CREATEMAN, t1.IBIZSAMPLE0012ID, t11.IBIZSAMPLE0012NAME, t1.IBIZSAMPLE0013ID, t1.IBIZSAMPLE0013NAME, t1.IBIZUNIPRODUCTID, t21.IBIZUNIPRODUCTNAME, t1.QUANTITY, t21.UNIT, t21.UNITPRICE, t1.UPDATEDATE, t1.UPDATEMAN FROM T_IBIZSAMPLE0013 t1  LEFT JOIN T_IBIZSAMPLE0012 t11 ON t1.IBIZSAMPLE0012ID = t11.IBIZSAMPLE0012ID  LEFT JOIN T_IBIZUNIPRODUCT t21 ON t1.IBIZUNIPRODUCTID = t21.IBIZUNIPRODUCTID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="hana">
		<![CDATA[ SELECT t1.\"QUANTITY\"*t21.\"UNITPRICE\" AS \"AMOUNT\", t1.\"CREATEDATE\", t1.\"CREATEMAN\", t1.\"IBIZSAMPLE0012ID\", t11.\"IBIZSAMPLE0012NAME\", t1.\"IBIZSAMPLE0013ID\", t1.\"IBIZSAMPLE0013NAME\", t1.\"IBIZUNIPRODUCTID\", t21.\"IBIZUNIPRODUCTNAME\", t1.\"QUANTITY\", t21.\"UNIT\", t21.\"UNITPRICE\", t1.\"UPDATEDATE\", t1.\"UPDATEMAN\" FROM \"T_IBIZSAMPLE0013\" t1  LEFT JOIN T_IBIZSAMPLE0012 t11 ON t1.IBIZSAMPLE0012ID = t11.IBIZSAMPLE0012ID  LEFT JOIN T_IBIZUNIPRODUCT t21 ON t1.IBIZUNIPRODUCTID = t21.IBIZUNIPRODUCTID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="mysql">
		<![CDATA[ SELECT t1.`QUANTITY`*t11.`UNITPRICE` AS `AMOUNT`, t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`IBIZSAMPLE0012ID`, t21.`IBIZSAMPLE0012NAME`, t1.`IBIZSAMPLE0013ID`, t1.`IBIZSAMPLE0013NAME`, t1.`IBIZUNIPRODUCTID`, t11.`IBIZUNIPRODUCTNAME`, t1.`QUANTITY`, t11.`UNIT`, t11.`UNITPRICE`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_IBIZSAMPLE0013` t1  LEFT JOIN T_IBIZUNIPRODUCT t11 ON t1.IBIZUNIPRODUCTID = t11.IBIZUNIPRODUCTID  LEFT JOIN T_IBIZSAMPLE0012 t21 ON t1.IBIZSAMPLE0012ID = t21.IBIZSAMPLE0012ID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="postgresql">
		<![CDATA[ SELECT t1.QUANTITY*t21.UNITPRICE AS AMOUNT, t1.CREATEDATE, t1.CREATEMAN, t1.IBIZSAMPLE0012ID, t11.IBIZSAMPLE0012NAME, t1.IBIZSAMPLE0013ID, t1.IBIZSAMPLE0013NAME, t1.IBIZUNIPRODUCTID, t21.IBIZUNIPRODUCTNAME, t1.QUANTITY, t21.UNIT, t21.UNITPRICE, t1.UPDATEDATE, t1.UPDATEMAN FROM T_IBIZSAMPLE0013 t1  LEFT JOIN T_IBIZSAMPLE0012 t11 ON t1.IBIZSAMPLE0012ID = t11.IBIZSAMPLE0012ID  LEFT JOIN T_IBIZUNIPRODUCT t21 ON t1.IBIZUNIPRODUCTID = t21.IBIZUNIPRODUCTID  
			]]>
    </sql>
    <!--数据查询[Default]-->
    <sql id="Default" databaseId="sqlserver">
		<![CDATA[ SELECT t1.[QUANTITY]*t21.[UNITPRICE] AS [AMOUNT], t1.[CREATEDATE], t1.[CREATEMAN], t1.[IBIZSAMPLE0012ID], t11.[IBIZSAMPLE0012NAME], t1.[IBIZSAMPLE0013ID], t1.[IBIZSAMPLE0013NAME], t1.[IBIZUNIPRODUCTID], t21.[IBIZUNIPRODUCTNAME], t1.[QUANTITY], t21.[UNIT], t21.[UNITPRICE], t1.[UPDATEDATE], t1.[UPDATEMAN] FROM [T_IBIZSAMPLE0013] t1  LEFT JOIN T_IBIZSAMPLE0012 t11 ON t1.IBIZSAMPLE0012ID = t11.IBIZSAMPLE0012ID  LEFT JOIN T_IBIZUNIPRODUCT t21 ON t1.IBIZUNIPRODUCTID = t21.IBIZUNIPRODUCTID  
			]]>
    </sql>
</mapper>

