映射文件:

<select id="selectKeyByUserId"  resultMap="Xxx">
        <![CDATA[
        SELECT * FROM 表名1
         where 1=1
            <if test="userId!=0">
            and ID=#{userId,jdbcType=NUMERIC}) 
            </if>
    </select>

dao层

public List<Xxx> selectKeyByUserId(long userId);

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userId' in 'class java.lang.Long'
    at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:380)
    at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:170)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:152)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:48)
    at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116)
    at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:97)
    at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:116)
    at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
    at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)
    at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)
    at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:33)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)
    at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)

... 89 more

出现原因
 这里出现的问题是在DAO方法中定义的参数 与 实体中定义的属性不一致 导致的。

解决方案:

dao层加@Param("userId")注解即可

public List<DictItem> selectKeyByUserId(@Param("userId") long userId);

Caused by: org.apache.ibatis.reflection.ReflectionException我碰到的情况,原因不唯一的更多相关文章

  1. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'zoneId' in 'class java.lang.String'

    本文为博主原创,未经允许不得而转载: 异常展示: dao层定义的接口为: public int getClientTotal(); 在mybatis中的sql为: <select id=&quo ...

  2. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'company' in 'class java.lang.String'

    Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...

  3. mybatis Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class .. with invalid types () or values (). Cause: java.lang.NoSuchMethodException: ...<init>()

    如果有带参数的构造器,编译器不会自动生成无参构造器.当查询需要返回对象时,ORM框架用反射来调用对象的无参构造函数,所以会导致此类异常 public Test(){ }

  4. org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String'

    Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...

  5. 【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 ...

  6. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empid' in 'class cn.happy.entity.Emp'

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.  Cause: org.apache.i ...

  7. Mybatis出错: Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.cyf.pojo.User with invalid types () or values ()

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ib ...

  8. Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ItemsCustom' in 'class com.pojo.OrderDetailCustom

    再用 junit 测试MyBatis时发现的错误: org.apache.ibatis.exceptions.PersistenceException: ### Error querying data ...

  9. org.apache.ibatis.reflection.ReflectionException

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...

随机推荐

  1. AC日记——自然数和分解 codevs 2549

    自然数和分解 思路: 水题: 代码: #include <bits/stdc++.h> using namespace std; ][]; int main() { cin>> ...

  2. linux 把用户加入一个组&从这个组中移除

    # usermod -a -G www zhou // zhou这个用户现在属于两个组 zhou www # groups zhou zhou : zhou www # gpasswd -d zhou ...

  3. 洛谷 P3919 【模板】可持久化数组(可持久化线段树/平衡树)-可持久化线段树(单点更新,单点查询)

    P3919 [模板]可持久化数组(可持久化线段树/平衡树) 题目背景 UPDATE : 最后一个点时间空间已经放大 标题即题意 有了可持久化数组,便可以实现很多衍生的可持久化功能(例如:可持久化并查集 ...

  4. POJ 1089 Intervals【合并n个区间/贪心】

    There is given the series of n closed intervals [ai; bi], where i=1,2,...,n. The sum of those interv ...

  5. BZOJ 4873 寿司餐厅(最大权闭合图 网络流)

    寿司餐厅 时间限制: 1 Sec  内存限制: 512 MB提交: 6  解决: 3[提交][状态][讨论版] 题目描述 Kiana 最近喜欢到一家非常美味的寿司餐厅用餐.每天晚上,这家餐厅都会按顺序 ...

  6. 通过邮箱验证注册——.net代码

    在写一些面向用户的网站类的程序时,必不可少的一个就是注册,通常情况下,我们会选择邮箱验证后注册,或者手机发送验证码注册.上篇文章中已经简单的描述了手机验证注册,这篇主要介绍一下邮箱验证. 邮箱验证的步 ...

  7. BZOJ 1116 [POI2008]CLO(并查集)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1116 [题目大意] Byteotia城市有n个towns,m条双向roads.每条ro ...

  8. File I/O知识点

    问题1:File类的作用? 解答:File 类用于访问文件或目录的属性.File类位于java.io包中. 问题2:流?及流的分类? 解答:流是指一连串流动的字符,是以先进先出的方式发送信息的通道.程 ...

  9. Problem C: 零起点学算法93——矩阵转置

    #include<stdio.h> int main() { ][],b[][]; while(scanf("%d%d",&n,&m)!=EOF) { ...

  10. 94.Txx考试

    2894 Txx考试  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description Txx是一个成绩很差的人,考试便成了他 ...