zoukankan      html  css  js  c++  java
  • 关于级联查询,mybatis

    <?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!= null">
    <!-- namespace:必须与对应的接口全类名一致 id:必须与对应接口的某个对应的方法名一致 <!DOCTYPE mapper PUBLIC
    "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -->

    <mapper namespace="">
    <resultMap type="HrsBabyHealth" id="HrsBabyHealthAll">
    <result property="babyId" column="BABY_ID"/>
    <result property="babaNo" column="BABA_NO"/>
    <result property="userId" column="USER_ID_"/>
    <result property="petName" column="PET_NAME"/>
    <result property="name" column="NAME"/>
    <result property="idCard" column="ID_CARD"/>
    <result property="genderId" column="GENDER_ID"/>
    <result property="birthday" column="BIRTHDAY"/>
    <result property="birthTime" column="BIRTH_TIME"/>
    <result property="inputDate" column="INPUT_DATE_"/>
    <result property="dataSource" column="DATA_SOURCE"/>
    <result property="orgName" column="ORG_NAME"/>
    <result property="className" column="CLASS_NAME"/>
    <result property="orgNameStr" column="ORG_NAMESTR"/>
    <result property="classNameStr" column="CLASS_NAMESTR"/>
    <result property="trueAge" column="TRUE_AGE"/>
    <result property="delStatue" column="DEL_STATUE"/>
    </resultMap>
    <select id="findHrsBabyHealthCount" parameterType="HrsBabyHealth" resultType="java.lang.Long">
    select count(*)
    from HRS_BABY_HEALTH
    <where>
    <if test = " babaNo != null"> BABA_NO = #{babaNo} </if>
    <if test = " userId != null">AND USER_ID_ = #{userId} </if>
    <if test = " petName != null">AND PET_NAME = #{petName} </if>
    <if test = " name != null">AND NAME = #{name} </if>
    <if test = " idCard != null">AND ID_CARD = #{idCard} </if>
    <if test = " genderId != null">AND GENDER_ID = #{genderId} </if>
    <if test = " birthday != null">AND BIRTHDAY = #{birthday} </if>
    <if test = " birthTime != null">AND BIRTH_TIME = #{birthTime} </if>
    <if test = " inputDate != null">AND INPUT_DATE_ = #{inputDate} </if>
    <if test = " dataSource != null">AND DATA_SOURCE = #{dataSource} </if>
    <!-- <if test = " orgName != null">AND ORG_NAME in (${orgName}) </if> -->
    <if test = " orgNameList != null">
    AND ORG_NAME in
    <foreach collection="orgNameList" item="item" index="index" separator="," open="(" close=")">
    ${item}
    </foreach>
    </if>
    <if test = " className != null">AND CLASS_NAME = #{className} </if>
    <if test = " trueAge != null">AND TRUE_AGE = #{trueAge} </if>
    <if test = " delStatue != null">AND DEL_STATUE = #{delStatue} </if>
    </where>
    </select>
    <select id="findHrsBabyHealthAllByWhere" parameterType="HrsBabyHealth" resultMap="HrsBabyHealthAll">
    select BABY_ID,BABA_NO,USER_ID_,PET_NAME,NAME,ID_CARD,GENDER_ID,BIRTHDAY,BIRTH_TIME,h.INPUT_DATE_,DATA_SOURCE,ORG_NAME,CLASS_NAME,TRUE_AGE,g.GROUP_NAME AS CLASS_NAMESTR,o.NAME_ AS ORG_NAMESTR,h.DEL_STATUE
    from HRS_BABY_HEALTH h
    LEFT JOIN hrs_group g ON g.GROUP_ID=h.CLASS_NAME
    LEFT JOIN organization_ o ON o.ORG_ID_=h.ORG_NAME
    <where>
    <if test = " babyId != null">AND BABY_ID = #{babyId} </if>
    <if test = " babaNo != null">AND BABA_NO = #{babaNo} </if>
    <if test = " userId != null">AND h.USER_ID_ = #{userId} </if>
    <if test = " petName != null">AND PET_NAME like '%'||#{petName}||'%' </if>
    <if test = " name != null">AND h.NAME like '%'||#{name}||'%' </if>
    <if test = " idCard != null">AND ID_CARD = #{idCard} </if>
    <if test = " genderId != null">AND GENDER_ID = #{genderId} </if>
    <if test = " birthday != null">AND h.BIRTHDAY = #{birthday} </if>
    <if test = " birthTime != null">AND h.BIRTH_TIME = #{birthTime} </if>
    <if test = " inputDate != null">AND h.INPUT_DATE_ = #{inputDate} </if>
    <if test = " dataSource != null">AND DATA_SOURCE = #{dataSource} </if>
    <if test = " orgNameList != null">
    AND h.ORG_NAME in
    <foreach item="item" index="index" collection="orgNameList"
    separator="," open ="(" close=")" >
    ${item}
    </foreach>
    </if>
    <if test = " className != null">AND h.CLASS_NAME = #{className} </if>
    <if test = " trueAge != null">AND h.TRUE_AGE = #{trueAge} </if>
    <if test = " delStatue != null">AND h.DEL_STATUE = #{delStatue} </if>
    </where>
    ORDER BY BABY_ID desc
    <if test = "start != null and limit != null">limit #{start},#{limit}</if>
    </select>
    </mapper>

  • 相关阅读:
    python os.walk()和os.path.walk()
    python学习之random模块
    java性能优化文章
    mysql和workbench的安装、创建实例、用户
    32位、64位与Java开发研究分析
    Web缓存
    深入分析 Java 中的中文编码问题
    eclipse+tomcat(eclipse自带插件) JSP修改后不生效问题
    今天给2010买的三星R428升级一下固态硬盘
    href="javascript:xxx(this);"和onclick="javascript:xxx(this);"的区别
  • 原文地址:https://www.cnblogs.com/Eilen/p/6733075.html
Copyright © 2011-2022 走看看