我遇到的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. 下拉框选择 <from:select>

  2. CentOS linux7 设置开机启动服务

    常用命令 描述                                 旧命令  新命令 使服务自动启动          chkconfig --level 3 http on  syste ...

  3. curl函数错误码对照信息表

  4. Windows服务 + Quartz.NET

    服务基础 安装管理员打开cmd cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 InstallUtil.exe Path_WinSvc.exe 或者 ...

  5. Ubuntu系统---终端下用g++进行c++项目

    Ubuntu系统---终端下用g++进行c++项目 目录 一.编译工具(g++/gcc)和编辑工具(vim/gedit)二.C语言 的编译与运行三.C++语言 的编译与运行四.gcc/g++的详细过程 ...

  6. Python3+Appium学习笔记07-元素定位工具UI Automator Viewer

    这篇主要说下如何使用UI Automator Viewer这个工具来定位元素.这个工具是sdk自带的.在sdk安装目录Tools目录下找到uiautomatorviewer.bat并启动它 ​ 如果启 ...

  7. BCB 中 Application->CreateForm 和 New 的一个区别

    Application->Create 和 NEW 的一个区别 最近写windows服务的时候,恰巧碰到一个问题.我建立了一个DataModal,然后在Datamodal的OnCreate 事件 ...

  8. Hadoop动态增加节点与删除节点

    Hadoop的全分布式安装网上也很多教程,踩过很多坑,整理不出来了……赶紧把增加删除节点留住. 均衡数据 (1)设置数据传输带宽为64M(默认值比较低) hdfs dfsadmin -setBalan ...

  9. input 设置 display:none后 jquery无法给input赋值

    问题出现场景:为什么要用 jquery给input赋值,为什么input带有display:none 在做字典查询的时候,查询参数有字典类型的treeSelect 下拉框,treeSelect渲染后, ...

  10. a标签中的javascript:void(0)和#的区别

    #包含了一个位置信息 默认的锚是#top 也就是网页的上端 而javascript:void(0)   仅仅表示一个死链接 void(0)用于执行某些处理,但是不整体刷新页面 javascript:v ...