Mybatis使用choose when
Mybatis使用<choose> <when>
例子: order by
<sql id="Base_OrderBy"><if test="orderBy != null and orderBy.size() > 0">order by<foreach collection="orderBy" item="item" separator=","><choose><when test="item.name == 'codeTabUuid'">CODE_TAB_UUID<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'code'">CODE<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'name'">NAME<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'codeType'">CODE_TYPE<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'parentUuid'">PARENT_UUID<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'upLimit'">UP_LIMIT<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'downLimit'">DOWN_LIMIT<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'srcCode'">SRC_CODE<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'srcName'">SRC_NAME<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'srcParentCode'">SRC_PARENT_CODE<if test="item.direction != null">${item.direction}</if></when><when test="item.name == 'sortValue'">SORT_VALUE<if test="item.direction != null">${item.direction}</if></when><otherwise /></choose></foreach></if></sql>
Mybatis使用choose when相关推荐
- Mybatis <choose> <when> <otherwise>
choose 标签是按顺序判断其内部 when 标签中的 test 条件出否成立,如果有一个成立,则 choose 结束.当 choose 中所有 when 的条件都不满则时,则执行 otherwis ...
- MyBatis选择Choose和条件IF用法
choose用法 <choose><when test="showType == 1">IFNULL(k.fname,'未知') as pro_name,& ...
- Mybatis的choose标签
1.choose标签介绍 choose标签作用条件判断来拼接指定的条件,它和if不太相同,choose似类于java中的switch语句用法,直要有条件成立,其它判断将得不到执行,如果所有条件都不成立 ...
- mybatis使用<choose> <when>
mybatis使用<choose> <when> 一.需求 后台使用orcale数据库,mybatis做持久层,前台搜索功能,根据类型搜索,但是数据库中没有类型字段, 所以需要 ...
- Mybatis choose使用
Mybatis的choose类似于java中的switch 具体用法如下: select * from table <where><choose><!-- when类似于 ...
- 动态SQL( if, choose, when, otherwise, trim, where, set, foreach标签讲解)
1 动态SQL# 那么,问题来了: 什么是动态SQL? 动态SQL有什么作用? 传统的使用JDBC的方法,相信大家在组合复杂的的SQL语句的时候,需要去拼接,稍不注意哪怕少了个空格,都会导致错误.My ...
- 狂神说-Mybatis笔记(总)
环境: JDK1.8 MySQL 8.0.23 maven 3.6.1 IDEA2020.3 框架:需要配置文件 官方中文文档:https://mybatis.org/mybatis-3/zh/ind ...
- ibatis里面if else 用法
公司原因,接触了ibatis,以前用mybatis 感觉ibatis不好用啊,连只有个if 没有else的用法 mybatis的choose,when,otherwise等记不住了就去查,很容易查到 ...
- MyBatis 动态元素 choose元素(when,otherwise)
choose元素 choose元素也可说是对它的属性做或(or)操作,当我们列出三个when表达式时,它会从第一个when开始判断,如果为真则直接结束choose元素.也就是说它的三个when最多只会 ...
- MyBatis 中的 choose、then、otherwise
MyBatis 中的 choose.then.otherwise 作用 MyBatis 提供的 choose.then.otherwise 标签,用起来有些像 Java 中的 switch .case ...
最新文章
- Windows下SVN权限配置过程详解
- 大家帮忙.谢谢!..(急急急急急)
- 项目性能优化(实现页面静态化1)
- mysql一些原生基本操作
- dns tunnel CC
- 成功解决 cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp” 和 cl: 命令行 error D8021 :无效的数值参数“/Wno-unused-function”
- mysql字符集,insert,update,delete,select
- webpack4.0各个击破(2)—— CSS篇
- RabbitMQ(1) - win+rabbitMQ
- Mysql 集成随机唯一id mysql unique number generation
- cocos2dx arm64 jpg格式的不显示_如何导出CocosCreator项目供cocos2dx加载
- AndroidStudio_开发工具的设置_布局编辑器的使用---Android原生开发工作笔记74
- python获取当前线程_Python爬虫(线程,进程)
- 一辆车撞到一位女孩的各种拍摄手法
- 基于CSS实现的尖角提示符
- 学术分享 | 没有导师的指导,研究生如何阅读文献、提出创见、写论文?
- 2021-08-27最大回文子串 leetcode
- cad刷新快捷键_47个快捷键、50个CAD技巧。
- 汇编语言里 eax, ebx, ecx, edx, esi, edi, ebp, esp 寄存器 含义
- 关于小程序 scroll