• 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">
    
    <mapper namespace="com.inspur.analysis.tool.ontology.linkType.dao.LinkTypeMapper">
    
        <resultMap type="com.inspur.analysis.tool.ontology.linkType.data.LinkType" id="linkType">
            <id property="linkUri" column="LINK_URI"/>
            <result property="uriHash" column="URI_HASH"/>
            <result property="baseTypeUri" column="BASE_TYPE_URI"/>
            <result property="linkLabel" column="LINK_LABEL"/>
            <result property="isAsymmetrical" column="IS_ASYMMETRICAL"/>
            <result property="aliase" column="ALIASE"/>
            <result property="pcName" column="P_C_NAME"/>
            <result property="pcAliase" column="P_C_ALIASE"/>
            <result property="cpName" column="C_P_NAME"/>
            <result property="cpAliase" column="C_P_ALIASE"/>
            <result property="detailIconUri" column="DETAIL_ICON_URI"/>
            <result property="detailIcon" column="DETAIL_ICON"/>
            <result property="edgeIconUri" column="EDGE_ICON_URI"/>
            <result property="edgeIcon" column="EDGE_ICON"/>
            <result property="isSys" column="IS_SYS"/>
            <result property="note" column="NOTE"/>
            <result property="creatorId" column="CREATOR_ID"/>
            <result property="createTime" column="CREATE_TIME"/>
            <result property="editorId" column="EDITOR_ID"/>
            <result property="editTime" column="EDIT_TIME"/>
            <result property="scn" column="SCN"/>
        </resultMap>
    
        <select id="existLinkTypeUri" parameterType="String"
                resultMap="linkType">
            SELECT * FROM OD_LINK_TYPE
            WHERE LINK_URI = #{linkUri}
        </select>
    
        <select id="isRootLinkType" parameterType="String"
                resultType="int">
            SELECT EXISTS(SELECT LINK_URI FROM OD_LINK_TYPE
                                          WHERE LINK_URI=BASE_TYPE_URI AND LINK_URI=#{linkUri})
        </select>
    
        <select id="deleteRootLinkType" parameterType="String">
            DELETE FROM OD_LINK_TYPE WHERE BASE_TYPE_URI=#{baseTypeUri}
        </select>
    
        <select id="getRootLinkTypeList"  resultMap="linkType">
            SELECT * FROM OD_LINK_TYPE
            WHERE LINK_URI =  BASE_TYPE_URI
        </select>
    
        <select id="getAllLinkTypeListByParent" parameterType="java.util.Map"
                resultMap="linkType">
            SELECT * FROM OD_LINK_TYPE
            <where>
                LINK_URI != BASE_TYPE_URI
                <if test="baseTypeUri != null">
                  AND BASE_TYPE_URI=#{baseTypeUri}
                </if>
            </where>
            <if test="orderfield != null" >
             ORDER BY 
               <choose>    
                    <when test="orderfield == 'linkUri'">    
                        LINK_URI ${orderdir} 
                    </when>  
                     <when test="orderfield == 'linkLabel'">    
                        LINK_LABEL ${orderdir} 
                    </when>  
                     <otherwise>
                       BASE_TYPE_URI ${orderdir}
                    </otherwise> 
                </choose>    
            </if>
        </select>
    
        <select id="getLinkTypeListByCondition" parameterType="java.util.Map"  resultMap="linkType">
            SELECT * FROM OD_LINK_TYPE
            <where>
                LINK_URI != BASE_TYPE_URI
                <if test="linkUri != null">
                   AND LINK_URI LIKE '%${linkUri}%'
                </if>
                <if test="linkLabel != null">
                    AND LINK_LABEL LIKE '%${linkLabel}%'
                </if>
                <if test="baseTypeUri != null">
                    AND BASE_TYPE_URI=#{baseTypeUri}
                </if>
            </where>
          <if test="orderfield != null" >
             ORDER BY 
               <choose>    
                    <when test="orderfield == 'linkUri'">    
                        LINK_URI ${orderdir} 
                    </when>  
                     <when test="orderfield == 'linkLabel'">    
                        LINK_LABEL ${orderdir} 
                    </when>  
                     <otherwise>
                       BASE_TYPE_URI ${orderdir}
                    </otherwise> 
                </choose>    
            </if>
        </select>
    
    </mapper>
    
  • 相关阅读:
    git 文件回退
    git reset
    开源
    android json js 算法 面试
    Android* 2.3.7
    Sqoop HBase Hadoop
    行业案例、技术



  • 原文地址:https://www.cnblogs.com/myitroad/p/7158704.html
Copyright © 2020-2023  润新知