[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的原因 ...
随机推荐
- string+DP leetcode-4.最长回文子串
5. Longest Palindromic Substring 题面 Given a string s, find the longest palindromic substring in s. Y ...
- Java基础加强-泛型
/*泛型*/ (泛型是给编译器看的) 泛型是提供给 /*javac编译器使用的*/,可以限定集合中的输入类型,让编译器挡住源程序中的非法输入,编译器编译带类型带类型说明的集合时,会去掉 "类 ...
- 配置Python、Django环境变量教程
配置环境变量 在Windows下你必须配置环境变量! 右击桌面或者你能看到的任何 此电脑.这台电脑或者我的电脑. 右击:属性 点击:高级系统设置 点击:环境变量 找到系统变量下的Path,双击 点击新 ...
- myeclipse 添加反编译插件
文件下载地址: 链接: https://pan.baidu.com/s/1th2goaA2aS45kO84dX1Bdg 密码: g1fu 先关闭myeclipse1.下载jad1.5.8g 下载后解压 ...
- 离线yum源挂载及yum服务器搭建
在进行现网环境搭建的时候,绝大多数情况下,centos或redhat(以下以centos为例)服务器是跟公网隔离的,因此需要找一台服务器挂载自己的yum源. 一.离线yum源包的制作 离线yum源可以 ...
- 跟着minium官网介绍学习minium-----(三)
注意:程序运行时在微信开发者工具当前页面为主,而不是每次运行都是从home页面开始 一 获取单个元素 get_element():在当前页面查询控件, 如果匹配到多个结果, 则返回第一个匹配到的结果 ...
- Why do we name variables in Tensorflow?
Reference:Stack Overflow. The name parameter is optional (you can create variables and constants wit ...
- python自动华 (十四)
Python自动化 [第十四篇]:HTML介绍 本节内容: Html 概述 HTML文档 常用标签 2. CSS 概述 CSS选择器 CSS常用属性 1.HTML 1.1概述 HTML是英文Hyper ...
- [Javascript] Convert a forEach method to generator
For example we have a 'forEach' method which can loop though a linked list: forEach(fn) { let node = ...
- 关于npm audit fix
https://blog.csdn.net/weixin_40817115/article/details/81007774 npm audit : npm@5.10.0 & npm@6,允许 ...