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 ...
随机推荐
- 教你用 Python 实现抖音热门表白软件
之前在群里看到有人发了一个抖音上很火的小视频,就是一个不正经的软件,运行后问你是不是愿意做我的朋友,但你没法点击到「不同意」!并且没办法直接关闭窗口! 很不正经,很流氓,有点适合我. 效果大概是这样的 ...
- java-07接口与继承
1.动手实验:继承条件下的构造方法调用 代码: package demo; class Grandparent{ public Grandparent(){ System.out.println(&q ...
- Milking Time(DP)
个人心得:一开始自己找状态,是这么理解的,只要前面一个满足就等于此时的值加上d(n-1),否则就是不挖此时的比较d(n-1)和 d(n-2)+cost,不过仔细一想忽略了很多问题,你无法确定n-2和此 ...
- LeetCode Construct String from Binary Tree
原题链接在这里:https://leetcode.com/problems/construct-string-from-binary-tree/#/description 题目: You need t ...
- java 守护线程整理
java中finally语句不走的可能存在system.exit(0)与守护线程 线程sleep采用TimeUnit类 设定线程的名字thread.getcurrentThread().setName ...
- Visualforce入门第五篇_2017.3.1
Visualforce添加过滤器,实现数据的筛选 参考原文:https://trailhead.salesforce.com/modules/visualforce_fundamentals/unit ...
- OpenWrt添加启动脚本
1.在 /etc/init.d 目录下建立文件 vi silabs #!/bin/sh /etc/rc.common # Copyright (C) 2006 OpenWrt.org START=93 ...
- c# OrderBy 实现List升序降序
本文转载自:http://blog.csdn.net/chadcao/article/details/8730132 1)前台代码 <%@ Page Language="C#" ...
- boost的asio接收单路大数据量udp包的方法
开发windows客户端接收RTP视频流,当h264视频达到1080P 60fps的时候,按包来调用recvfrom的函数压力比较大,存在丢包的问题,windows的完成端口的性能效果当然可以解决这个 ...
- JavaScript基本概念A
简介 如果需要了解这些概念, 您应该熟悉 JS 的基本知识. 弱类型 在也无需绞尽脑汁觉得到底采用 float.double,int 还是 short 或是 long 还是 String.只需这样定义 ...