我遇到的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&lt;to_date(#{date},'yyyy-MM-dd')
    </select>

    <select id="getExpiredCount"  resultType="integer">
        SELECT COUNT (*) as cnt from ${tableName} where created_datetime&lt;to_date(#{date},'yyyy-MM-dd')  AND ROWNUM&lt;#{rowNum}
    </select>

    <delete id="sweepAwayExpired">
        delete from ${tableName} where created_datetime&lt;to_date(#{date},'yyyy-MM-dd') AND ROWNUM&lt;#{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的避免的更多相关文章

  1. 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 ...

  2. mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误

    最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...

  3. 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 ...

  4. 怪事年年有,今天特别多!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 ...

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

  6. 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 ...

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

  8. mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...

  9. Spring boot结合mybatis开发的报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),经过排查确定是没有找到xml的原因 ...

随机推荐

  1. 百度定位SDK 返回error code : 162 latitude : 4.9E-324 lontitude : 4.9E-324

    Android应用使用百度定位SDK 返回error code : 162 latitude : 4.9E-324 lontitude : 4.9E-324 在使用百度定位SDK时遇到一个非常郁闷的问 ...

  2. Dephi 10.3.3试用报告

    官方没有正式发布,但出了下载及keygen,具体内容我在这篇内容写了:Delphi 10.3.3最新消息 . 也可以去Delphi多层开发交流QQ群:209321818找相关的keygen. 今早来就 ...

  3. 用pythoninstall cefpython打包exe,制作自己的浏览器

    cefpython浏览器 介绍 用pythoninstall cefpython打包exe,制作自己的浏览器, 软件架构 PyInstaller: 3.4 Python: 3.5.4 Platform ...

  4. MySQL数据库的二进制安装、源码编译和基础入门操作

    一.MySQL安装 (1)安装方式: 1 .程序包yum安装 优点:安装快,简单 缺点:定死了各个文件的地方,需要修改里边的相关配置文件,很麻烦 2 .二进制格式的程序包:展开至特定路径,并经过简单配 ...

  5. 8.vue-resource 数据请求基本实现

    1.vue-resource 实现 get, post, jsonp请求:https://github.com/pagekit/vue-resource 注意: 除了 vue-resource 实现数 ...

  6. less混合

    混合(mixin)变量 .border{ border: 5px solid pink; } .box{ width: 300px;height:300px; .border; } => .bo ...

  7. PAT乙级1044

    题目链接 https://pintia.cn/problem-sets/994805260223102976/problems/994805279328157696 题解 需要注意的几个点: 题目有指 ...

  8. mysql总复习

    目录 数据库操作 库操作 表操作 数据行操作 表关系操作 单表操作 外键创建 多表联查 pymysql模块 索引 主键索引 唯一索引 普通索引 数据库操作 库操作 create database 库名 ...

  9. JavaScript基础习题

    1.实现输入框的双向绑定 解析:所谓双向绑定,即view->model, model->view,可以考虑对象劫持,监听对象属性的变化 <input type="input ...

  10. 5-修改windows的远程桌面端口3389

    一.注意点 1.Windows远程桌面端口默认是3389,是一个高危端口,所以需要改为其他的: 2.修改完注册表后,要重启机器,才能生效: 二.操作步骤 1.打开注册表 命令:regedit 2.进入 ...