zoukankan      html  css  js  c++  java
  • select

    1.String 参数 作为if 条件

    mybatis mapper.xml sql  当parameterType为String时 任何参数都必须为_parameter(比如原先为参数为key),若果没有_parameter,提示错误There is no getter of  'username' in java.lang.string

    int pagingCount(String key);
    
    <select id="pagingCount" resultType="int" parameterType="string">
             SELECT 
                count(1)
            FROM 
                users 
            WHERE 1=1
            <if test="key != null and '' != key">
                name = #{key} or username = #{key}
            </if>
         </select>
    <select id="pagingCount" resultType="int" parameterType="string">
             SELECT 
                count(1)
            FROM 
                users 
            WHERE 1=1
            <if test="_parameter != null and '' != _parameter">
                and name = #{_parameter} or username = #{_parameter}
            </if>
         </select>

     2. list 作为必须条件,otherwise 直接返回false ,结果集返回null

    List<Role> queryRolesByOrgIds(@Param("ids") Set<Integer> ids);
    <select id="queryRolesByOrgIds" resultMap="roleMap" parameterType="list" >
          select r.id,r.name,r.code,r.app_code,r.parent_id from ts_role r
              join tm_org_role ro
              on r.id = ro.role_id
          where
          <choose>
              <when test="ids!=null and ids.size>0">
                  ro.org_id in
                  <foreach collection="ids" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
              </when>
              <otherwise>
                  false
              </otherwise>
          </choose>
      </select>
  • 相关阅读:
    TBDR下msaa 在metal vulkan和ogles的解决方案
    Load store action in vulkan & ogles 的解决方案
    百度 我日你全家
    metal sample code
    NativeRenderingPlugin IOS
    ranch实现游戏服务器
    erlang游戏开发tcp
    Erlang 命令行监控工具
    rebar安装及创建项目
    erlang中如何调试程序
  • 原文地址:https://www.cnblogs.com/yangfei-beijing/p/8529015.html
Copyright © 2011-2022 走看看