zoukankan      html  css  js  c++  java
  • Mybatis 报错 There is no getter for property named '***' in 'class java.lang.String'

      在mapper.xml中 , 如果单参数是String类型 , 且在sql语句中对参数进行了判断 , 如下 when 中的判断 , 如果出现 if 判断也是一样的。都需要把判断中的参数用 _parameter 来代替 ,。

      另外orcal中判断字段是否为空需要使用 is null , 同理,判断不为空使用 is not null 。

      错误查询:

    <select id = "select"  resultMap="ResultMap" parameterType="String">
    select
    name,code,parent,level
    from
    table
    <where>
    <choose>
    <when test="code != null and code !=''">
    and code = #{code}
    </when>
    <otherwise>
    and code is null
    </otherwise>
    </choose>
    </where>
    </select>

      正确查询:


    <select id = "select" resultMap="ResultMap" parameterType="String">
    select
    name,code,parent,level
    from
    table
    <where>
    <choose>
    <when test="_parameter !=null and _parameter !=''">
    and code = #{code}
    </when>
    <otherwise>
    and code is null
    </otherwise>
    </choose>
    </where>
    </select>
  • 相关阅读:
    网站初学笔记1
    如何在新项目中使用曾经创建的用户控件
    C#用户控件的一些尝试
    MVC的含义
    Chrome浏览器面板基础了解
    VScode快捷键
    Windows中的键盘快捷方式
    node.js状态码
    JavaScript小结
    Truncate a string
  • 原文地址:https://www.cnblogs.com/gczmn/p/7475113.html
Copyright © 2011-2022 走看看