在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>

Mybatis 报错 There is no getter for property named '***' in 'class java.lang.String'的更多相关文章

  1. mybatis 错误: There is no getter for property named '*' in 'class java.lang.String解决

    现象: mybatis mapper.xml 的sql里如果直接使用了想要传入的变量,比如: <select id="selectXx" resultType="i ...

  2. Mybatis查询报错:There is no getter for property named '*' in 'class java.lang.String

    问题: 执行查询时报错:There is no getter for property named '*' in 'class java.lang.String 原因: 传过去的参数为识别.本例为 p ...

  3. 【spring mvc】后台API查询接口,get请求,后台Date字段接收前台String类型的时间,报错default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'createDate';

    后台API查询接口,get请求,后台Date字段接收前台String类型的时间筛选条件 后台接口接收 使用的实体 而createDate字段在后台实体中是Date类型 报错信息: org.spring ...

  4. Mybatis报错: There is no getter for property named xxx

    在mapper文件中函数的形参上加上注解. 例如: 出现了如下错误:核心错误提示就是There is no getter for property named xxx     ### Error qu ...

  5. mybatis报错,There is no getter for property named 'templateName' in 'class

    There is no getter for property named 'templateName' in 'class 主要原因是因为mapper.xml 的语句有错误,导致在bean里找不到相 ...

  6. 【MyBatis学习06】_parameter:解决There is no getter for property named in class java.lang.String

    我们知道在mybatis的映射中传参数,只能传入一个.通过#{参数名} 即可获取传入的值. Mapper接口文件: public int delete(int id) throws Exception ...

  7. _parameter:解决There is no getter for property named in class java.lang.String

    我们知道在mybatis的映射中传参数,只能传入一个.通过#{参数名} 即可获取传入的值. Mapper接口文件: public int delete(int id) throws Exception ...

  8. mybatis There is no getter for property named '*' in 'class java.lang.String

    1.原因 server层     xxxx.get("1234") map <if test="aaa != null and aaa.id != null and ...

  9. MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'

    在写MyBatis映射文件中,我要传入一个 int 类型的参数,在映射文件中用 'test' 中进行比较,我花了很长时间百度,发现都是不靠谱的方法,有把数字在比较时转成字符串用 equals 比较的. ...

随机推荐

  1. Linux之定时任务Crond使用

    Linux之定时任务Crond使用 一.用法 crond服务是linux系统自带的服务,是不需要手动安装的: crond服务是一种守护进程: Linux中的用户使用contab命令来配置corn任务: ...

  2. js模块化编程之彻底弄懂CommonJS和AMD/CMD!

    先回答我:为什么模块很重要? 答:因为有了模块,我们就可以更方便地使用别人的代码,想要什么功能,就加载什么模块.但是,这样做有一个前提,那就是大家必须以同样的方式编写模块,否则你有你的写法,我有我的写 ...

  3. [android] logcat简介

    /****************2016年5月4日 更新**************************/ 知乎:Android中的LogCat为什么叫作LogCat? 刘贺: linux有个命 ...

  4. [android] 采用aidl绑定远程服务

    aidl:android interface definition language 安卓接口定义语言 在两个不同的应用程序里面使用同一个接口 使用场景:调用支付宝服务进行支付 先写远程服务端Seri ...

  5. Java线程池 Executor框架概述

    线程池的意义 循环利用线程资源,避免重复创建和销毁线程 线程池的任务是异步执行的,只要提交完成就能快速返回,可以提高应用响应性 Java线程池还有一个很重要的意义:Java线程池就是JDK 5 推出的 ...

  6. python基础学习(十)字符串

    字符串的定义 字符串 就是 一串字符,是编程语言中表示文本的数据类型 在 Python 中可以使用 一对双引号 " 或者 一对单引号 ' 定义一个字符串 虽然可以使用 \" 或者 ...

  7. C# SqlBulkCopy类批量导入 测试

    一.功能说明 1.可以选择,只导入部分列,或者导入全部列. 2.导入速度的确比一般sql要快. 3.不用写sql语句 ----------------------------------------- ...

  8. gulp插件构建项目 压缩js、css、image、zip、web服务、跨域等插件

    推荐一个很好文: https://github.com/lin-xin/blog/issues/2 匹配符 *.**.!.{} gulp.src('./js/*.js') // * 匹配js文件夹下所 ...

  9. Docker compose 调用外部文件及指定hosts 例子

    cat docker-compose.yml version: '3.4' services: klvchen: image: ${IMAGE_NAME} restart: always # dock ...

  10. 中国 AI 天才养成计划:清华姚班和 100 个「张小龙」

    https://daily.zhihu.com/story/9653612?from=timeline&isappinstalled=0   AI财经社,专注未来,以及更好的生活 真正的 AI ...