用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错

  1. There is no getter for property named 'sleevetype' in 'class java.lang.Integer

解决方法一:

原因在于测试条件写法有误,

  1. <if test="sleevetype==0"><!-- 专属 -->
  2. exclusive=1
  3. </if>
  4. <if test="sleevetype!=0"><!-- 非专属 -->
  5. sleeve_type=#{sleevetype} and exclusive=0
  6. </if>

正确写法:

  1. <if test="_parameter==0"><!-- 专属 -->
  2. exclusive=1
  3. </if>
  4. <if test="_parameter!=0"><!-- 非专属 -->
  5. sleeve_type=#{sleevetype} and exclusive=0
  6. </if>

不管传的参数是什么,都要改成"_parameter" 。

解决方法二:

是在DAO接口声明部分在形参前加上 @Param("sleevetype")

实际上,当DAO接口有多个参数时,需要使用@Param,或者用Map,或者对象。

MyBatis查询传一个参数时报错:There is no getter for property named 'sleevetype' in 'class java.lang.Integer的更多相关文章

  1. Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'。

    Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'. 错误Li ...

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

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

  3. mybatis之org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'time' in 'class java.lang.String'

    mybatis接口 List<String> getUsedCate(String time); 配置文件 <select id="getUsedCate" pa ...

  4. Bug--Mybatis报错:There is no getter for property named 'id' in 'class java.lang.Integer'

    Mybatis 添加@Param("")注释就可以了

  5. Mybatis中传参包There is no getter for property named 'XXX' in 'class java.lang.String'

    Mybatis中传参包There is no getter for property named 'XXX' in 'class java.lang.String' 一.发现问题 <select ...

  6. SSM框架报错分析(一)——There is no getter for property named 'XXX' in 'class java.lang.String'

    一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType=&quo ...

  7. 【Mybatis】mybatis查询报错org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'areaName' in 'class java.lang.String'

    mybatis查询报错: Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pro ...

  8. 已解决: mybatis报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxx' in 'class java.lang.String'

    最近在练习MyBatis时 进行姓名的模糊查询时候出现 org.apache.ibatis.exceptions.PersistenceException: ### Error querying da ...

  9. 当传入数据只有一个时mybatis中<if>判断会出现There is no getter for property named 'subjectId' in 'class java.lang.Intege

    用"_parameter"代替当前参数 正确: <select id="selectSubjectByPId" parameterType="j ...

随机推荐

  1. 系统广播 android.intent.action.KILL_BACKGROUND_SERVICE

    Broadcast: Intent { act=android.intent.action.KILL_BACKGROUND_SERVICE.com.xxx.VoiceAssistant flg=0x1 ...

  2. Lenovo GTX960M 配置CUDA

    文章是出自我的原创,是写在新浪博客里面的:http://blog.sina.com.cn/s/blog_13b7eb5b20102wvxw.html 首先,软件的版本你选择很重要,我们配置了两天才成功 ...

  3. [CareerCup] 8.6 Jigsaw Puzzle 拼图游戏

    8.6 Implement a jigsaw puzzle. Design the data structures and explain an algorithm to solve the puzz ...

  4. Arduino智能小车实践学习报告

    Arduino智能小车实践学习报告 参与人员: 20135316 王剑桥 20135312 吴汉彦 20135319 朱锂 一. 背景了解: 单片机:将中央处理单元CPU(进行运算.控制).随机存储器 ...

  5. Android 中 appcompat_v7与各类资源报错问题

    最近导一个项目进eclipse弄了一天都弄不好,先总结如下 首先按照网上其他同志的导入sdk/extras下的appcompat_v7项目.然后 发现 我们这里已经更新到6.0了,也就是说,我们报错的 ...

  6. cryptDB安装分析

    cryptDB的安装脚步是用ruby语言写的,由于这里对ruby语言不熟悉,只能做简答的分析.我们先看看cryptDB的目录结构. 主要的目录有bins.doc.main.udf目录,下面我们通过分析 ...

  7. WRONGTYPE Operation against a key holding the wrong kind of value

    今天改动代码,一运行就跑错了,错误原因: 因为redis中已经存在了相同的key, 而且key对应的值类型并不是Set,而是SortSet(改动前):再调用smembers时,抛出此错误. 解决方法: ...

  8. ibatis中的$和#的区别

    介绍 在Ibatis中我们使用SqlMap进行Sql查询时需要引用参数,在参数引用中遇到的符号#和$之间的区分为,#可以进行与编译,进行类型匹配,而$不进行数据类型匹配,例如: select * fr ...

  9. java ee 中文乱码的问题

    java ee 中文乱码的问题 发生中文乱码的三种情况 (一) 表单form Post 方法 直接在服务器中设置 request.setCharacterEncoding("utf-8&qu ...

  10. IntelliJ Idea13无法创建maven模板

    一.错误信息: -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment v ...