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

    <!--该方法用于重写mybatis中selectById方法，以实现查询逻辑属性-->
	<select id="selectById"  resultMap="IBIZTASKTEAMResultMap" databaseId="mysql">
        <![CDATA[select t1.* from (SELECT t1.`ACCOUNT`, t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`IBIZTASKTEAMID`, t1.`IBIZTASKTEAMNAME`, t1.`ROLE`, t1.`ROOT`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_IBIZTASKTEAM` t1  ) t1 where ibiztaskteamid=#{id}]]>
    </select>

    <!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
    <resultMap id="IBIZTASKTEAMResultMap" type="cn.ibizlab.core.sample.domain.IBIZTASKTEAM" autoMapping="true">
		<id property="ibiztaskteamid" column="ibiztaskteamid" /><!--主键字段映射-->
		<result property="root" column="root" />
            
		
		<!--通过mybatis自动注入关系属性[主实体]，fetchType="lazy"为懒加载配置 -->
		<association property="taskteam" javaType="cn.ibizlab.core.sample.domain.IBIZTASK" column="root" select="cn.ibizlab.core.sample.mapper.IBIZTASKMapper.selectById" fetchType="lazy"></association>
    </resultMap>

	<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_IBIZTASKTEAM_IBIZTASK_ROOT] -->
	 <select id="selectByRoot" resultMap="IBIZTASKTEAMResultMap">
         select t1.* from (
                <include refid="Default" />
			 ) t1
			 where  root=#{ibiztaskid}
     </select>

    <!--数据集合[Default]-->
	 <select id="searchDefault"  parameterType="cn.ibizlab.core.sample.filter.IBIZTASKTEAMSearchContext"  resultMap="IBIZTASKTEAMResultMap">
         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="mysql">
		<![CDATA[ SELECT t1.`ACCOUNT`, t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`IBIZTASKTEAMID`, t1.`IBIZTASKTEAMNAME`, t1.`ROLE`, t1.`ROOT`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_IBIZTASKTEAM` t1  
			]]>
    </sql>
    <!--数据查询[View]-->
    <sql id="View" databaseId="mysql">
		<![CDATA[ SELECT t1.`ACCOUNT`, t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`IBIZTASKTEAMID`, t1.`IBIZTASKTEAMNAME`, t1.`ROLE`, t1.`ROOT`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_IBIZTASKTEAM` t1  
			]]>
    </sql>
</mapper>

