Mybatis使用<choose> <when>

例子: order by

  <sql id="Base_OrderBy"><if test="orderBy != null and orderBy.size() &gt; 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相关推荐

  1. Mybatis <choose> <when> <otherwise>

    choose 标签是按顺序判断其内部 when 标签中的 test 条件出否成立,如果有一个成立,则 choose 结束.当 choose 中所有 when 的条件都不满则时,则执行 otherwis ...

  2. MyBatis选择Choose和条件IF用法

    choose用法 <choose><when test="showType == 1">IFNULL(k.fname,'未知') as pro_name,& ...

  3. Mybatis的choose标签

    1.choose标签介绍 choose标签作用条件判断来拼接指定的条件,它和if不太相同,choose似类于java中的switch语句用法,直要有条件成立,其它判断将得不到执行,如果所有条件都不成立 ...

  4. mybatis使用<choose> <when>

    mybatis使用<choose> <when> 一.需求 后台使用orcale数据库,mybatis做持久层,前台搜索功能,根据类型搜索,但是数据库中没有类型字段, 所以需要 ...

  5. Mybatis choose使用

    Mybatis的choose类似于java中的switch 具体用法如下: select * from table <where><choose><!-- when类似于 ...

  6. 动态SQL( if, choose, when, otherwise, trim, where, set, foreach标签讲解)

    1 动态SQL# 那么,问题来了: 什么是动态SQL? 动态SQL有什么作用? 传统的使用JDBC的方法,相信大家在组合复杂的的SQL语句的时候,需要去拼接,稍不注意哪怕少了个空格,都会导致错误.My ...

  7. 狂神说-Mybatis笔记(总)

    环境: JDK1.8 MySQL 8.0.23 maven 3.6.1 IDEA2020.3 框架:需要配置文件 官方中文文档:https://mybatis.org/mybatis-3/zh/ind ...

  8. ibatis里面if else 用法

    公司原因,接触了ibatis,以前用mybatis 感觉ibatis不好用啊,连只有个if 没有else的用法 mybatis的choose,when,otherwise等记不住了就去查,很容易查到 ...

  9. MyBatis 动态元素 choose元素(when,otherwise)

    choose元素 choose元素也可说是对它的属性做或(or)操作,当我们列出三个when表达式时,它会从第一个when开始判断,如果为真则直接结束choose元素.也就是说它的三个when最多只会 ...

  10. MyBatis 中的 choose、then、otherwise

    MyBatis 中的 choose.then.otherwise 作用 MyBatis 提供的 choose.then.otherwise 标签,用起来有些像 Java 中的 switch .case ...

最新文章

  1. Windows下SVN权限配置过程详解
  2. 大家帮忙.谢谢!..(急急急急急)
  3. 项目性能优化(实现页面静态化1)
  4. mysql一些原生基本操作
  5. dns tunnel CC
  6. 成功解决 cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp” 和 cl: 命令行 error D8021 :无效的数值参数“/Wno-unused-function”
  7. mysql字符集,insert,update,delete,select
  8. webpack4.0各个击破(2)—— CSS篇
  9. RabbitMQ(1) - win+rabbitMQ
  10. Mysql 集成随机唯一id mysql unique number generation
  11. cocos2dx arm64 jpg格式的不显示_如何导出CocosCreator项目供cocos2dx加载
  12. AndroidStudio_开发工具的设置_布局编辑器的使用---Android原生开发工作笔记74
  13. python获取当前线程_Python爬虫(线程,进程)
  14. 一辆车撞到一位女孩的各种拍摄手法
  15. 基于CSS实现的尖角提示符
  16. 学术分享 | 没有导师的指导,研究生如何阅读文献、提出创见、写论文?
  17. 2021-08-27最大回文子串 leetcode
  18. cad刷新快捷键_47个快捷键、50个CAD技巧。
  19. 汇编语言里 eax, ebx, ecx, edx, esi, edi, ebp, esp 寄存器 含义
  20. 关于小程序 scroll

热门文章

  1. Spring AOP中Introduction的使用
  2. web视频(点播/直播)播放器选型
  3. linux ubuntu开放端口查看,ubuntu/linux下查看端口使用情况
  4. 毁掉一个年轻最好的办法,就是向他鼓吹财务自由
  5. java 中== 和equal的区别
  6. EVA改进(点锐度算法)图像清晰度评价方法C++实现
  7. 网秦安全盾 原理分析
  8. Python3-pandas
  9. Pro InfoPath 2007
  10. easyui数据表格批量删除(datagrid 的deleteRow方法)