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>
MyBatis基本查询、条件查询、查询排序的更多相关文章
- 指定查询条件,查询对应的集合List(单表)
TestDao.java(测试类) @Test public void findCollectionByConditionNoPage(){ ApplicationContext ac = new ...
- SolrJ查询条件组合查询实现——(十六)
带查询条件的实现原理: 查询按钮被包在一个大表单,表单还有三个隐藏域,一个商品筛选,一个 价格,一个排序,每次点击查询时候清空三个隐藏域,就带着一个大条件去查询;点击下面的筛选条件时,给隐藏域的筛选条 ...
- jeecg 扩展封装查询条件 时间段查询
使用jeecg框架开发的小伙伴们知道,添加查询条件,通常是我们加一个配置(query="true")就可以将该字段设置为查询条件.简单方便.但是这样的配置查询条件仅适用于输入框输入 ...
- 3. 如何封装查询条件与查询结果到map中
public Map<String, Object> queryOrderStatus(String orderNo) { // 查询到的结果与查询的条件一一对应,封装到map中! Str ...
- 【mysql】 mybatis实现 主从表 left join 1:n 一对多 分页查询 主表从表都有查询条件 【mybatis】count 统计+JSON查询
mybatis实现 主从表 left join 1:n 一对多 分页查询 主表从表都有查询条件+count 需求: ======================================= ...
- JPA实现复杂条件分页查询
相信熟悉Hibernate的人对于ORM给编程带来的便利于快捷一定不陌生,相对于MyBatis等需要编写复杂的SQL语句,ORM映射为我们带来的便利显而易见.但是,在获得便利的同时,失去的便是灵活性, ...
- mybatis配合pagehelper分页助手查询
Maven: 参考: springBoot2.x整合pagehelper5.1.2:https://blog.csdn.net/Carlson_Chis/article/details/8563748 ...
- Mybatis的插件 PageHelper 分页查询使用方法
参考:https://blog.csdn.net/ckc_666/article/details/79257028 Mybatis的一个插件,PageHelper,非常方便mybatis分页查询,国内 ...
- eas之EntityViewInfo对象mainQuery中查询条件
EntityViewInfo对象mainQuery中查询条件: 添加查询字段:(Sql语句中的selectz子句内容) SelecttorItemCollection sic=new Sele ...
- mysql连表操作是先连表还是先查询条件
mysql连表操作是先连表还是先查询条件 一.总结 一句话总结: 连表操作时:先根据查询条件和查询字段确定驱动表,确定驱动表之后就可以开始连表操作了,然后再在缓存结果中根据查询条件找符合条件的数据 1 ...
随机推荐
- HNOI2004 宠物收养所 (平衡二叉树)
题目链接 平衡树基础题,用于测试各种平衡树的性能(雾) treap: #include<bits/stdc++.h> typedef long long ll; using namespa ...
- tableau学习笔记—1
第一部分 第一章 数据可视化 1.1 用数据讲故事 1.2 数据不只是数字 1.3 在数据中寻找什么(关系.模式.异常) 第二章 Tableau概述 2.1 Tableau概述 2.2 产品简介 第三 ...
- Linux-CentOS7 安装VMware Workstation 12
转自:http://blog.csdn.net/aoshilang2249/article/details/48656107 1.下载VMware 衔接地址 http://www.vmware.com ...
- 【LeetCode】004. Median of Two Sorted Arrays
题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the ...
- 【LeetCode】029. Divide Two Integers
Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...
- c++运行时决定数组大小 variable-length array
本文由Suzzz原创,发布于 http://www.cnblogs.com/Suzzz/p/4117431.html,转载请保留此声明 variable-length array是C99添加的一个特性 ...
- java List 等份截取
/** * 描述: 等份截取 * @author eyesmooon * @param list * @param size * @return * @date:2018年11月8日 下午8:00:3 ...
- 四川第七届 C Censor (字符串哈希)
Censor frog is now a editor to censor so-called sensitive words (敏感词). She has a long text pp. Her j ...
- springmvc----demo2---a->b--bai
1.jsp 2.jsp 3.jsp LianxiAction: package com.etc.controller; import javax.servlet.http.HttpSession; i ...
- Python函数(五)-高阶函数
函数接收的参数可以是数字,字符串,列表,元组,字典,集合,也可以是另一个函数,那么这个接收一个函数作为参数的函数就称为高阶函数 # -*- coding:utf-8 -*- __author__ = ...