Caused by: org.apache.ibatis.reflection.ReflectionException我碰到的情况,原因不唯一
映射文件:
<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我碰到的情况,原因不唯一的更多相关文章
- 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 ...
- 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 ' ...
- mybatis Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class .. with invalid types () or values (). Cause: java.lang.NoSuchMethodException: ...<init>()
如果有带参数的构造器,编译器不会自动生成无参构造器.当查询需要返回对象时,ORM框架用反射来调用对象的无参构造函数,所以会导致此类异常 public Test(){ }
- 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 ' ...
- 【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 ...
- 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 ...
- 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 ...
- 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 ...
- org.apache.ibatis.reflection.ReflectionException
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...
随机推荐
- (翻译)Xamarin.Essentials: 移动应用的跨平台 API
原文地址:https://blog.xamarin.com/xamarin-essentials-cross-platform-apis-mobile-apps/ 当使用 Xamarin 开发 IOS ...
- tomcat放置静态html页面
因公司tomcat网站需要部署一个html的静态网页上去 在项目目录下建立了一个 /usr/local/tomcat/apache-tomcat-brain-api/webapps/ROOT/html ...
- Rsync+Inotify 搭建实时同步数据
1.安装软件包 # yum install inotify-tools # yum -y install rsync 2.同步机器相互添加信任 [root@host-10-0-100-106 ~]# ...
- BotBuilder Nodejs示例查看
关于Bot Framework知识,可以参考<Nodejs Bot学习> 本文是根据bot framework官方示例<https://github.com/Microsoft/Bo ...
- POJ 3259 Wormholes【最短路/SPFA判断负环模板】
农夫约翰在探索他的许多农场,发现了一些惊人的虫洞.虫洞是很奇特的,因为它是一个单向通道,可让你进入虫洞的前达到目的地!他的N(1≤N≤500)个农场被编号为1..N,之间有M(1≤M≤2500)条路径 ...
- IoC控制反转和DI依赖注入
控制反转(Inversion of Control,英文缩写为IoC)是框架的重要特征,并非面向对象编程的专用术语.它与依赖注入(Dependency Injection,简称DI ...
- 洛谷——P2784 化学1(chem1)- 化学合成
P2784 化学1(chem1)- 化学合成 题目背景 蒟蒻HansBug在化学考场上,挠了无数次的头,可脑子里还是一片空白. 题目描述 眼下出现在蒟蒻HansBug面前的是一个化学合成题,据他所知, ...
- Xamarin.Forms教程下载安装JDK配置环境变量
Xamarin.Forms教程下载安装JDK配置环境变量 Xamarin.Form环境配置下载安装JDK JDK是编程Java程序必须的软件.也许有人会问我们用的C#为什么还有Java呢?这是因为我们 ...
- 概率dp学习记录
论文参考 汤可因<浅谈一类数学期望问题的解决方法> 反正是很神奇的东西吧..我脑子不好不是很能想得到. bzoj 1415 1415: [Noi2005]聪聪和可可 Time Limit: ...
- Eden的退役记
好久没更博客了, 这篇随笔不同于之前的学术性随笔.游记,只是来发泄一下自己的情感,回忆一下自己的OI经历…… 五年的OI生涯结束了 初一:懵懂的我刚接触了OI,被其功能吸引.由于运气好过了初赛,然而复 ...