大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 MyBatis子查詢的方法

MyBatis子查詢的方法

更新時間:2021-12-20 09:52:52 來源:動力節點 瀏覽1552次

首先,父查詢basechildResultmap:

<? 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” >   
<映射器命名空間="com.dayhr.web.module.hr.td.elearn.mapper.TrainerMapper"  >    
    <!--表字段--> 
      < resultMap id ="BaseResultMap" type ="com.dayhr.web.module.hr.td.elearn.model.Trainer"  > 
        < id column ="id" property ="id" jdbcType ="CHAR"  /> 
        < result column ="name" property ="name" jdbcType ="VARCHAR"  /> 
        < result column ="title" property ="title" jdbcType ="VARCHAR"  /> 
        <結果列="推薦"屬性="recommend" jdbcType ="INTEGER"  /> 
        < result column ="trainer_type_id" property ="trainerTypeId" jdbcType ="CHAR"  /> 
        < result column ="phone" property ="phone" jdbcType ="VARCHAR"  /> 
        <結果列="email"屬性="email" jdbcType ="VARCHAR"  /> 
        <結果列="地址"屬性="地址"jdbcType ="VARCHAR"  /> 
        <結果column ="pro_field" property ="proField" jdbcType ="VARCHAR"  /> 
        < result column ="intro" property ="intro" jdbcType ="VARCHAR"  /> 
        < result column ="head_img" property ="headImg" jdbcType = "VARCHAR"  /> 
        < result column ="labels" property ="labels" jdbcType ="VARCHAR"  /> 
        < result column ="corp_id"屬性="corpId" jdbcType ="整數" /> 
        < result column ="creater_id" property ="createrId" jdbcType ="INTEGER"  /> 
        < result column ="create_time" property ="createTime" jdbcType ="TIMESTAMP"  /> 
        < result column ="modifier_id" property =" modifierId" jdbcType ="INTEGER"  /> 
        < result column ="modify_time" property ="modifyTime" jdbcType ="TIMESTAMP" /> 
      </ 結果映射>      
      <!--  返回頁面bean --> 
      < resultMap id ="BaseResultRespMap" type ="com.dayhr.web.module.hr.td.elearn.response.TrainerResp"  > 
        < id column ="id" property =" id" jdbcType ="CHAR"  /> 
        < result column ="name" property ="name" jdbcType ="VARCHAR"  /> 
        < result column ="title" property ="title" jdbcType ="VARCHAR"  />
        <結果欄=“推薦” property="recommend" jdbcType="INTEGER" />
        <result column="trainer_type_id" property="trainerTypeId" jdbcType="CHAR" />
        <result column="phone" property="phone" jdbcType="VARCHAR" />
        <result column="email" property="email" jdbcType="VARCHAR" />
        <result column="address" property="address" jdbcType="VARCHAR" />
        <result column="pro_field" property="proField" jdbcType="VARCHAR" />
        <result column="intro" property="intro" jdbcType="VARCHAR" />
        <result column="head_img" property="headImg" jdbcType="VARCHAR" />
        <result column="labels" property="labels" jdbcType="VARCHAR" />
        <result column="corp_id" property="corpId" jdbcType="INTEGER" />
        <result column="creater_id" property="createrId" jdbcType="INTEGER" />
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="modifier_id" property="modifierId" jdbcType="INTEGER" />
        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />        
        <result column="trainerTypeName" property="trainerTypeName" />
        <result column="trainerLabels" property="trainerLabels" />
      </resultMap>      
      <!--  Subquerice -->
    <resultMap id="BaseChildResultMap" type="com.dayhr.web.module.hr.td.elearn.response.TrainerResp" extends="BaseResultRespMap">
        <collection property="trainerLabels" 
            ofType="com.dayhr.web.module.hr.td.elearn.response.TrainerLabelResp" 
            select="com.dayhr.web.module.hr.td.elearn.mapper.TrainerLabelMapper.selecLabels" column="labels">
        </collection>
    </resultMap>    
      <!--  Foundation field in the table -->
    <sql id="Base_Column_List">
        t.id, t.name, t.title, t.recommend, t.trainer_type_id, t1.name AS trainerTypeName, 
        t.phone, t.email, t.address, t.pro_field, t.intro, t.head_img, t.labels, t.corp_id,
        t.creater_id, t.create_time, t.modifier_id, t.modify_time
    </sql>    
    <!--  Query conditions    -->
    <sql id="select_Where_Clause">    
       <where>    
            1=1
            <if test="id != null and id != ''">
                AND t.id = #{id }    
            </if>
            <if test="name != null and name != ''">
                AND t.name like CONCAT('%',#{name },'%' )    
            </if>
            <if test="corpId != null and corpId != ''">
                AND corp_id = #{corpId }    
            </if>
            <if test="trainerTypeId != null and trainerTypeId != ''">
                AND t.trainer_type_id = #{trainerTypeId }    
            </if>        
            <if test="orderBy != null and orderBy != ''">
                ORDER BY ${orderBy } ${sortType }
            </if>    
       </where>
    </sql>      
      <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
        delete from t_hr_td_trainer
        where id = #{id }
      </delete>      
      <insert id="insert" parameterType="com.dayhr.web.module.hr.td.elearn.model.Trainer" useGeneratedKeys="true" keyProperty="id">
        insert into t_hr_td_trainer (id, name, title, 
          recommend, trainer_type_id, phone, 
          email, address, pro_field, 
          intro, head_img, labels, 
          corp_id, creater_id, create_time, 
          modifier_id, modify_time)
        values (#{id,jdbcType=CHAR}, #{name,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, 
          #{recommend,jdbcType=INTEGER}, #{trainerTypeId,jdbcType=CHAR}, #{phone,jdbcType=VARCHAR}, 
          #{email,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{proField,jdbcType=VARCHAR}, 
          #{intro,jdbcType=VARCHAR}, #{headImg,jdbcType=VARCHAR}, #{labels,jdbcType=VARCHAR}, 
          #{corpId,jdbcType=INTEGER}, #{createrId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
          #{modifierId,jdbcType=INTEGER}, #{modifyTime,jdbcType=TIMESTAMP})
      </insert>      
      <update id="updateByPrimaryKey" parameterType="com.dayhr.web.module.hr.td.elearn.model.Trainer" >
          UPDATE t_hr_td_trainer
        <set>
            <if test="name != null and name != ''">
                name = #{name }, 
            </if>
            <if test="title != null and title != ''">
                title = #{title },
            </if>    
            <if test="recommend != null and recommend != ''">
                recommend = #{recommend },
            </if>
            <if test="trainerTypeId != null and trainerTypeId != ''">
                trainer_type_id = #{trainerTypeId },
            </if>
            <if test="phone != null and phone != ''">
                phone = #{phone },
            </if>
            <if test="email != null and email != ''">
                email = #{email },
            </if>
            <if test="address != null and address != ''">
                address = #{address },
            </if>
            <if test="proField != null and proField != ''">
                pro_field = #{proField },
            </if>
            <if test="intro != null and intro != ''">
                intro = #{intro },
            </if>
            <if test="headImg != null and headImg != ''">
                head_img = #{headImg },
            </if>
            <if test="labels != null and labels != ''">
                labels = #{labels },
            </if>
            <if test="corpId != null and corpId != ''">
                corp_id = #{corpId },
            </if>
            <if test="createrId != null and createrId != ''">
                creater_id = #{createrId },
            </if>    
            <if test="createTime != null and createTime != ''">
                create_time = #{createTime },
            </if>    
            <if test="modifierId != null and modifierId != ''">
                modifier_id = #{modifierId },
            </if>
            <if test="modifyTime != null and modifyTime != ''">
                modify_time = #{modifyTime }
            </if>
        </set>
        WHERE id = #{id }
      </update>      
      <select id="selectByPrimaryKey" resultMap="BaseChildResultMap" parameterType="java.lang.String" >
        SELECT
        <include refid="Base_Column_List" />
        FROM t_hr_td_trainer t
        LEFT JOIN t_hr_td_trainertype t1 ON t.trainer_type_id = t1.id
        WHERE t.id = #{id }
      </select>      
      <select id="selectAll" resultMap="BaseResultMap" >
        select 
            id, name, title, recommend, trainer_type_id, phone, email, address, pro_field, 
            intro, head_img, labels, corp_id, creater_id, create_time, modifier_id, modify_time
        from t_hr_td_trainer
      </select>      
    <select id="selectListByCondition" parameterType="com.dayhr.web.module.hr.td.elearn.param.TrainerQueryParam" resultMap="BaseChildResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM t_hr_td_trainer t
        LEFT JOIN t_hr_td_trainertype t1 ON t.trainer_type_id = t1.id          
        <include refid="select_Where_Clause" />
    </select>        
</mapper>

Subproof id = "SELECLABELS":注意這里的Value對應父查詢結果中的Labels:

<? 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” >    
<映射器命名空間="com.dayhr.web.module.hr.td.elearn.mapper.TrainerLabelMapper"  >    
    <!--  對應表字段--> 
      < resultMap id ="BaseResultMap" type ="com.dayhr.web.module.hr.td.elearn.model.TrainerLabel"  > 
        < id column ="id" property ="id "  /> 
        < result column ="trainer_label" property ="trainerLabel" jdbcType ="VARCHAR"  /> 
        < result column ="built_in" property ="builtIn" jdbcType ="INTEGER"  /> 
        <結果列="corp_id"屬性="corpId" jdbcType ="INTEGER"  /> 
        < result column ="creater_id" property ="createrId" jdbcType ="INTEGER"  /> 
        < result column ="creater_time" property ="createrTime" jdbcType ="TIMESTAMP"  /> 
        <結果列="modifier_id"屬性="modifierId" jdbcType ="INTEGER"  /> 
        <結果列="modify_time"屬性="modifyTime" jdbcType ="TIMESTAMP"  /> 
      </結果地圖>      
      <!--  返回字段--> 
      < resultMap id ="BaseResultRespMap" type ="com.dayhr.web.module.hr.td.elearn.response.TrainerLabelResp"  > 
        < id column ="id" property =" id"  /> 
        < result column ="trainer_label" property ="trainerLabel" jdbcType ="VARCHAR"  /> 
        < result column ="built_in" property ="builtIn" jdbcType ="INTEGER"  /> 
        <結果列="corp_id"屬性="corpId" jdbcType ="INTEGER"  /> 
        < result column ="creater_id" property ="createrId" jdbcType ="INTEGER"  /> 
        < result column ="creater_time" property ="createrTime" jdbcType ="TIMESTAMP"  /> 
        <結果列="modifier_id"屬性="modifierId" jdbcType ="INTEGER"  /> 
        <結果列="modify_time"屬性="modifyTime" jdbcType ="TIMESTAMP"  /> 
        <結果列="labels"屬性="labels"  /> 
      </ resultMap >      
      <!--  表中的基礎字段--> 
    < sql id ="Base_Column_List" >
        id、trainer_label、built_in、corp_id、creater_id、creater_time、modifier_id、modify_time
    </ sql >    
    <!--  查詢條件    --> 
    < sql id ="select_Where_Clause" >     
       < where >    
            1=1
            < if test ="id != null and id != ''" >
                AND id = #{id }    
            </if>
            <if test="corpId != null and corpId != ''">
                AND corp_id = #{corpId }    
            </if>
            <if test="trainerLabel != null and trainerLabel != ''">
                AND trainer_label like CONCAT('%',#{trainerLabel },'%' )    
            </if>    
            <if test="orderBy != null and orderBy != ''">
                ORDER BY ${orderBy } ${sortType }
            </if>    
       </where>
    </sql>      
      <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
        delete from t_hr_td_trainerlabel
        where id = #{id,jdbcType=CHAR}
      </delete>      
      <insert id="insert" parameterType="com.dayhr.web.module.hr.td.elearn.model.TrainerLabel" useGeneratedKeys="true" keyProperty="id">
        insert into t_hr_td_trainerlabel (id, trainer_label, built_in, corp_id, 
          creater_id, creater_time, modifier_id, 
          modify_time)
        values (#{id },#{trainerLabel,jdbcType=VARCHAR}, #{builtIn,jdbcType=INTEGER}, #{corpId,jdbcType=INTEGER}, 
          #{createrId,jdbcType=INTEGER}, #{createrTime,jdbcType=TIMESTAMP}, #{modifierId,jdbcType=INTEGER}, 
          #{modifyTime,jdbcType=TIMESTAMP})
      </insert>      
      <update id="updateByPrimaryKey" parameterType="com.dayhr.web.module.hr.td.elearn.model.TrainerLabel" >
        UPDATE t_hr_td_trainerlabel
        <set>
            <if test="trainerLabel != null and trainerLabel != ''">
                trainer_label = #{trainerLabel }, 
            </if>
            <if test="builtIn != null and builtIn != ''">
                built_in = #{builtIn },
            </if>
            <if test="corpId != null and corpId != ''">
                corp_id = #{corpId },
            </if>
            <if test="createrId != null and createrId != ''">
                creater_id = #{createrId },
            </if>    
            <if test="createTime != null and createTime != ''">
                create_time = #{createTime },
            </if>    
            <if test="modifierId != null and modifierId != ''">
                modifier_id = #{modifierId },
            </if>
            <if test="modifyTime != null and modifyTime != ''">
                modify_time = #{modifyTime }
            </if>
        </set>
        WHERE id = #{id }
      </update>      
      <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
        select 
            id, trainer_label, built_in, corp_id, creater_id, creater_time, modifier_id, modify_time
        from t_hr_td_trainerlabel
        where id = #{id }
      </select>      
      <select id="selectAll" resultMap="BaseResultMap" >
        select 
            id, trainer_label, built_in, corp_id, creater_id, creater_time, modifier_id, modify_time
        from t_hr_td_trainerlabel
      </select>      
      <!--  Verify that the label exists -->
    <select id="checkLabel" parameterType="com.dayhr.web.module.hr.td.elearn.param.TrainerLabelQueryParam" resultType="Integer">
        SELECT COUNT(*)
        FROM t_hr_td_trainerlabel 
        <include refid="select_Where_Clause" />
    </select>    
    <!--  Press the condition query tag -->
    <select id="selectLabelList" resultMap="BaseResultRespMap" parameterType="com.dayhr.web.module.hr.td.elearn.param.TrainerLabelQueryParam" >
        SELECT 
        <include refid="Base_Column_List" />
        FROM t_hr_td_trainerlabel 
        <include refid="select_Where_Clause" />
      </select>      
      <!--  Subproof in () will report an error, add '0' processing -->
      <select id="selecLabels" resultMap="BaseResultRespMap" >
        select 
            id, trainer_label, built_in, corp_id, creater_id, creater_time, modifier_id, modify_time
        from t_hr_td_trainerlabel
        where id in ('0'??    <if test="value != null and value.length !=0">??      ,${value }??      </if>??      )
      </select>      
</mapper>

 

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 日日夜夜国产 | 日本亚洲a | 老司机午夜在线 | 免费国产免费福利视频 | 久久视频精品a线视频在线观看 | 国产69精品久久久久9999 | 国产成人麻豆精品 | 久久亚洲精中文字幕冲田杏梨 | 奇米888888| 99精品免费在线 | 国产精品国产自线在线观看 | 免费一级毛片清高播放 | 精品中文字幕一区二区三区四区 | 亚洲一区二区三区高清网 | 奇米七七七 | 四虎影永久地址www 四虎影永久在线高清免费 四虎影永久在线观看精品 四虎影永久在线观看网址 四虎影院.com | 一本久道久久综合中文字幕 | 国产一区二区亚洲精品天堂 | 成人私人影院www片免费高清 | 欧美日韩在线播放 | 天天操天天干视频 | 国产精品青草久久 | 国产亚洲精品久久久久91网站 | 91麻豆精品国产91久久久久久 | 日本强不卡在线观看 | 国产福利在线观看第二区 | 国产亚洲精品国产一区 | 久国产精品久久精品国产四虎 | 波多野结衣免费播放 | 日本吻胸抓胸激烈视频网站 | 成人免费牛牛在线视频 | 99久久综合国产精品免费 | 成人嫩草研究院永久网址 | 国产成人精品亚洲日本在线 | 免费一级a毛片在线播出 | 亚欧有色亚欧乱色视频 | 久久精品国产半推半就 | 天天干天天噜 | 久久国产精品免费看 | 国产综合色香蕉精品五月婷 | 宅男噜噜噜66一区二区 |