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>
相关文章推荐
- MyBatis基本查询、条件查询、查询排序
- oracle心得1--oracle简介@基本sql语句@条件查询@排序数据理论与案例
- oracle心得1--oracle简介@基本sql语句@条件查询@排序数据理论与案例
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- Oracle学习之路(一):oracle简介+基本sql语句+条件查询+排序数据理论与案例
- Oracle学习笔记 -- day03 修改密码、基本查询、条件查询、模糊查询、排序查询
- oracle心得1--oracle简介@基本sql语句@条件查询@排序数据理论与案例
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- NHibernate(2) HQL 条件查询(QBC) - 分页,统计,排序
- 按照数组的形式排序+条件切换切换查询
- 按照数组的形式排序+条件切换切换查询
- 以淘宝商品搜索漫谈查询条件的排序对效率的影响(SQL查询性能优化,附调优(性能诊断)DMV)
- Oracle中实现查询结果按照in中条件排序 InStr函数
- Oracle 学习:PL/SQL循序渐进全面学习教程--课程一 PL/SQL 基本查询与排序
- Oracle基本查询过滤排序实例
- 动态多条件查询分页以及排序(一)--MVC与Entity Framework版url分页版
- Oracle(二)---------条件查询与排序数据
- 使用SPQuery进行条件查询和排序
- MSSQL和MYSQL中select where in的查询结果按where条件顺序排序的方法
- 【原创】StreamInsight查询系列(七)——基本查询操作之基础排序