您的位置:首页 > 其它

MyBatis基本查询、条件查询、查询排序

2017-07-13 09:13 423 查看
<?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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐