[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的原因 ...
随机推荐
- phpstorm+xdebug+mvc
前一段时间自己琢磨出来,今天又给忘了,还去t00ls发帖.... 写到这里备忘 拿这个yxcms举例子 版本: yxcms1.2.1 源码:http://pan.baidu.com/s/1pJM1CP ...
- KVM虚拟机高级设置——08 管理远程虚拟机
在搭建KVM环境——07 带GUI的Linux上安装KVM图形界面管理工具介绍了KVM图形化管理工具,这款工具除了可以管理本地KVM虚拟外,还可以管理远程KVM虚拟机. 输入113机器密码 输入yes ...
- MySQL授权(用户权限)
一.mysql查询与权限 (二)授权 用户管理: 设置用户密码 前期准备工作: 停止服务 将配置文件当中的skip-grant-tables删除掉 重启服务: 执行修改命令 查看用户状态(如果数据过多 ...
- Apache Maven setting.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Soft ...
- less运算
less里面是可以有运算的,任何数字,颜色或者变量都可以参与与暗算,运算应该被包裹在括号中. @test_width:300px; .box_width{ width: (@test_width ...
- mysql全量和增量备份详解(带脚本)
在日常运维工作中,对mysql数据库的备份是万分重要的,以防在数据库表丢失或损坏情况出现,可以及时恢复数据. 下面对这种备份方案详细说明下:1.MySQLdump增量备份配置执行增量备份的前提条件是M ...
- Java基础 线程的通信的三个方法/ 交替数数线程 / 生产者&消费者线程问题
线程通讯笔记: /** 线程通信 三个方法: * wait(): 调用该方法 是该调用的方法的线程释放共享资源的锁,进入等待状态,直至被唤醒 * notify() : 可以唤醒队列中的第一个等待同一共 ...
- 2018年5月20日--西安icpc邀请赛打铁总结
2018年5月20日--西安icpc邀请赛打铁总结 事后诸葛亮 大致回顾一下比赛,29号的热身赛和30号的正式赛. 热身赛总共三道题,一个小时,没有AC一道题目. A题是一个几何题目,审题时犯了一个 ...
- MATLAB中.m文件生成.dll
1.配置编译环境 在命令行窗口输入: mbuild -setup 如果出现以下提示信息说明成功: 如果提示信息为: 错误使用mbuild(line 164) Unable to complete su ...
- Android Studio 3.5.2添加依赖库
因为要连接服务器的数据库,百度了一下经验,需要添加一些mysql库,看了一下经验,没有找到3.5.2版本的添加依赖库的教程. 因为新版本的androidstudio有一些不同,作以记录. 比如我们要添 ...