博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
阅读量:7091 次
发布时间:2019-06-28

本文共 2569 字,大约阅读时间需要 8 分钟。

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.dao.mapper.UserInfoMapper.countByExample        at org.apache.ibatis.binding.MapperMethod$SqlCommand.
(MapperMethod.java:196) at org.apache.ibatis.binding.MapperMethod.
(MapperMethod.java:44) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy93.countByExample(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java

报错原因是Mapper.xml文件中没有id为countByExample的语句

 

如果出现:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

一般的原因是Mapper interfacexml文件的定义对应不上,需要检查包名namespace函数名称等能否对应上,需要比较细致的对比,

我经常就是写错了一两个字母搞的很长时间找不到错误

按以下步骤一一执行:

1:检查xml文件所在的package名称是否和interface对应的package名称一一对应

2:检查xml文件的namespace是否和xml文件的package名称一一对应

3:检查函数名称能否对应上

4:去掉xml文件中的中文注释

5:随意在xml文件中加一个空格或者空行然后保存

一般来说到此就可以排除错误了

http://blog.csdn.net/softwarehe/article/details/8889206

 

mybatis Mapper插件中,updateByPrimaryKey 方法在使用时,入参必须包含id,

实际使用的sql如下:

2016-11-14 11:23:18.885 DEBUG 640 --- [ main] t.m.s.m.U.updateByPrimaryKey : ==> Preparing: UPDATE user_info SET username = ?,password = ?,usertype = ?,enabled = ?,qq = ?,email = ?,tel = ? WHERE Id = ?

2016-11-14 11:23:18.915 DEBUG 640 --- [ main] t.m.s.m.U.updateByPrimaryKey : ==> Parameters: test1(String), 12345678(String), 1(String), null, null, null, null, null
2016-11-14 11:23:18.924 DEBUG 640 --- [ main] t.m.s.m.U.updateByPrimaryKey : <== Updates: 0

 

如果只想更新指定字段的值,可以使用api:   userInfoMapper.updateByPrimaryKeySelective

/**     * 根据主键更新属性不为null的值     *     * @param record     * @return     */    @UpdateProvider(type = BaseUpdateProvider.class, method = "dynamicSQL")    int updateByPrimaryKeySelective(T record);

 

你可能感兴趣的文章
[二] java8 函数式接口详解 函数接口详解 lambda表达式 匿名函数 方法引用使用含义 函数式接口实例 如何定义函数式接口...
查看>>
为什么 c = tf.matmul(a, b) 不立即执行矩阵乘法?
查看>>
Linux 变量引用和命令替换
查看>>
MS推荐的命名指南
查看>>
各大互联网公司架构演进之路汇总
查看>>
[转载].NET平台测试驱动开发模拟框架Moq简明教程(简介)
查看>>
xmlHttp
查看>>
Eclipse编译报Javascript和jquery错的解决办法
查看>>
C#字符串的简单用法
查看>>
EXPORT_SYMBOL的使用并以使用do_adjtimex调节内核tick_length(滴答长度)为例的说明...
查看>>
[转]WIN7服务一些优化方法
查看>>
(转)Markov Chain Monte Carlo
查看>>
Zabbix 常见问题处理整理
查看>>
PI AAE (Advanced Adapter Engine) 介绍一
查看>>
OEA体验:查询面板
查看>>
什么是VC维?
查看>>
SuperMap IS.NET自定义Action之兴趣点标注(转)
查看>>
HDOJ-1035 搜索模拟问题[深搜]
查看>>
C 猴子选大王(亚瑟夫环)
查看>>
关于Android中的SlidingMenu中的用法
查看>>