[MyBatis]org.apache.ibatis.binding.BindingException的避免
我遇到的org.apache.ibatis.binding.BindingException问题是因为Mapper.java中接口和SQL的参数多于一个,Mybatis不知道如何一一对应,解决方法是加上@param注解,手动告诉MyBatis如何去对应。代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hy.mapper.SweepawayMapper">
<select id="selectCleanExpiredParams" resultType="java.lang.String">
select name||':'||value from Clean_Expired_Params order by sort
</select>
<select id="findTableExist" resultType="integer">
SELECT COUNT (*) as cnt FROM ALL_TABLES WHERE table_name = UPPER(#{tableName})
</select>
<select id="getAllExpiredCount" resultType="integer">
SELECT COUNT (*) as cnt from ${tableName} where created_datetime<to_date(#{date},'yyyy-MM-dd')
</select>
<select id="getExpiredCount" resultType="integer">
SELECT COUNT (*) as cnt from ${tableName} where created_datetime<to_date(#{date},'yyyy-MM-dd') AND ROWNUM<#{rowNum}
</select>
<delete id="sweepAwayExpired">
delete from ${tableName} where created_datetime<to_date(#{date},'yyyy-MM-dd') AND ROWNUM<#{rowNum}
</delete>
</mapper>
而接口的写法是:
package com.hy.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
@MyMapper
public interface SweepawayMapper {
List<String> selectCleanExpiredParams();
int findTableExist(String tableName);// 一个参数MyBati能认出来
int getAllExpiredCount(@Param("tableName") String tableName,@Param("date") String date);// 多个参数得告诉MyBatis如何区分
int getExpiredCount(@Param("tableName") String tableName,@Param("date") String date,@Param("rowNum") int rowNum);
int sweepAwayExpired(@Param("tableName") String tableName,@Param("date") String date,@Param("rowNum") int rowNum);
}
--END-- 19/10/17 8:21
[MyBatis]org.apache.ibatis.binding.BindingException的避免的更多相关文章
- MyBatis—— org.apache.ibatis.binding.BindingException: Type interface com.web.mybatis.i.PersonMapper is not known to the MapperRegistry.
报错信息: Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interfac ...
- mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误
最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [1, 0, param1, param2]
Spring+mybatis错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bi ...
- 怪事年年有,今天特别多!org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'empno' not found. Available parameters are [emp, deptno, param1, param
错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Binding ...
- MyBatis 传List参数 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'idList' not found.
在MyBatis传入List参数时,MyBatis报错:nested exception is org.apache.ibatis.binding.BindingException: Paramete ...
- SpringBoot整合Mybatis注解版---update出现org.apache.ibatis.binding.BindingException: Parameter 'XXX' not found. Available parameters are [arg1, arg0, param1, param2]
SpringBoot整合Mybatis注解版---update时出现的问题 问题描述: 1.sql建表语句 DROP TABLE IF EXISTS `department`; CREATE TABL ...
- MyBatis笔记----报错Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@41cf53f9: startup ...
- mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...
- Spring boot结合mybatis开发的报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),经过排查确定是没有找到xml的原因 ...
随机推荐
- 【导出导入】IMPDP table_exists_action 参数的应用
转自:https://yq.aliyun.com/articles/29337 当使用IMPDP完成数据库导入时,如遇到表已存在时,Oracle提供给我们如下四种处理方式:a.忽略(SKIP,默认行为 ...
- SAP官方发布的ABAP编程规范
最近有朋友在公众号后台给我留言,"Jerry啊,你最近写的都是一些SAP研究院里面用到的新技术,能不能写点SAP传统的开发技术比如ABAP相关的东西"? 其实Jerry在刚开始写这 ...
- ASE19团队项目beta阶段Backend组 scrum7 记录
本次会议于12月13日,19:30在微软北京西二号楼sky garden召开,持续10分钟. 与会人员:Hao Wang, Lihao Ran, Xin Kang 请假人员:Zhikai Chen 每 ...
- MySQL5.7安装详解及常见安装问题解决
数据库安装 Python开发使用mysql数据库5.5版本以上(django2.0之后放弃mysql5.5之前的支持),在mysql版本当中5.7之前的版本都有.exe或者.msi的可执行安装文件,但 ...
- 微信小程序开发(十三)安卓手机调用wx.getConnectedWifi API失败
安卓手机调用wx.getConnectedWifi API失败,返回的错误码是12000.需要先startWifi 接口: wx.startWifi({ success(res) { console. ...
- 2.Storm集群部署及单词统计案例
1.集群部署的基本流程 2.集群部署的基础环境准备 3.Storm集群部署 4.Storm集群的进程及日志熟悉 5.Storm集群的常用操作命令 6.Storm源码下载及目录熟悉 7.Storm 单词 ...
- python3 random
一.random 1.生成伪随机数 2.伪随机数是可预测的,严格意义上不具有随机性质,通常用数学公式的方法(比如统计分布,平方取中等)获得 3.正如数列需要有首项,产生伪随机数需要一个初值用来计算整个 ...
- dubbo的初探
1.RPC 基本概念1.1 RPC 协议(Remote Procedure Call Protocol)远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议 ...
- [转载]Java进程物理内存远大于Xmx的问题分析
进程物理内存远大于Xmx的问题分析 问题描述 最近经常被问到一个问题,”为什么我们系统进程占用的物理内存(Res/Rss)会远远大于设置的Xmx值”,比如Xmx设置1.7G,但是top看到的Res的值 ...
- csrf简单明了( 转发)
https://www.daguanren.cc/post/csrf-introduction.html csrf_token = request.META.get('CSRF_COOKIE') re ...