我遇到的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. socket技术详解

    https://blog.csdn.net/weixin_39634961/article/details/80236161 socket编程是网络常用的编程,我们通过在网络中创建socket关键字来 ...

  2. 安卓已过时的ProgressDialog对话框

    private ProgressDialog mDialog; private Handler mHandler; //初始化Handler //初始化 mDialog = new ProgressD ...

  3. C#在代码中编写输出debug信息-类Debug的使用

    文章:C# 的两种debug 方法 文章:C#跟踪和调试程序-Debug类使用 很全面的文章,可以仔细学习使用下. 文章:C#调试类 没有仔细看. 关键字:Debug类和Trace类有什么区别? 微软 ...

  4. LevelDB的源码阅读(一)

    源码下载 git clone https://github.com/google/leveldb.git 项目结构 db/, 数据库逻辑 doc/, MD文档 helpers/, LevelDB内存版 ...

  5. 前端知识体系:JavaScript基础-作用域和闭包-JavaScript的作用域和作用域链

    JavaScript的作用域和作用域链 作用域: 变量的作用域无非两种:全局作用域和局部作用域 全局作用域: 最外层函数定义的变量拥有全局作用域.即对任何内部函数来说都是可以访问的. <scri ...

  6. paramiko远程上传下载文件

    import paramiko import sys user = "root" pwd = " # 上传文件 def sftp_upload_file(server_p ...

  7. 002_FreeRTOS临界段代码

    (一)临界段代码也叫做临界区,是指那些必须完整运行,不能被打断的代码段 (二)FreeRTOS 与 临 界 段 代 码 保 护 有 关 的 函 数 有 4 个,两个是任务级的临界段代码保护,两个是中断 ...

  8. 037_自动添加防火墙规则,开启某些服务或端口(适用于 RHEL7)

    #!/bin/bash#设置变量定义需要添加到防火墙规则的服务和端口号#使用 firewall-cmd --get-services 可以查看 firewall 支持哪些服务 service=&quo ...

  9. Razor传值到js

    1.Asp.net MVC 3 中Session与ViewBag传值到Js中 http://www.cnblogs.com/wintersun/archive/2012/06/04/2534975.h ...

  10. 把Cstring类型的字符串转化为char* 字符串;

    int char_leng; Cstring str="abcd"; char_leng=str.GetLength();//获取字符串长度 char *str_temp=(cha ...