zoukankan      html  css  js  c++  java
  • 【备忘】mybatis的条件判断用<choose>

    mybatis并没有if..else,在mybatis的sql mapper文件中,条件判断要用choose..when..otherwise。
     
    <choose>
      <when test="status == 'PROCES' or status == 'PENDNG'"> and batcol.status in('PROCES','PENDNG')</when>
      <when test="status == 'PREAUD'"> and batcol.status = '--'</when>
      <otherwise> and batcol.status = #{status,jdbcType=CHAR}</otherwise>
    </choose>
     
    <if test="status != null and status != 'all'" >
      <choose>
        <when test="status == 'PROCES' or status == 'PENDNG'"> and batcol.status in('PROCES','PENDNG')</when>
        <when test="status == 'PREAUD'"> and batcol.status = '--'</when>
        <otherwise> and batcol.status = #{status,jdbcType=CHAR}</otherwise>
      </choose>
    
    </if>
    
    
    choose为一个整体,
    when表示if ,(when可重复,即实现if..else if..else if..
    otherwise表示else。
    注意: test里的等号用==,而不是=。
  • 相关阅读:
    openGL
    shader
    安卓2
    安卓
    错误整理
    3D图形学
    shaderlab
    MVC
    一、TCP扫描技术
    端口扫描技术
  • 原文地址:https://www.cnblogs.com/buguge/p/10691744.html
Copyright © 2011-2022 走看看