[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的原因 ...
随机推荐
- flask的多个url对应同一个视图函数
# -*- coding: utf-8 -*- from flask import Flask app = Flask(__name__) @app.route('/') def index(): r ...
- 【python】python 自动发邮件
一.一般发邮件的方法 Python对SMTP支持有smtplib和email两个模块,email负责构造邮件,smtplib负责发送邮件. 注意到构造MIMETEXT对象时,第一个参数就是邮件正文,第 ...
- stm32f429 仿真器不能识别芯片
刚买的野火挑战者开发板,下载几次程序后,忽然就不能通过JLINK下载了,提示如下错误: No Cortex-M Device found in JTAG chain. Error: Flash Dow ...
- fwrite、write、fread、read
1. write和read 1.1 write: 头文件:#include<unistd.h> 原型: ssize_t write(int fd,const void*buf,size_t ...
- SQL Server 对接MySQL 数据库
1.在SQL SERVER服务器上安装MYSQL ODBC驱动; 驱动下载地址:http://dev.mysql.com/downloads/connector/odbc/ 2.安装好后,在管理工具- ...
- LeetCode--字符串
1.给定字符串s,分区s使得分区的每个子字符串都是回文. 返回s的所有可能的回文分区.例如,给定s =“aab”,返回 [ ["aa","b"], [" ...
- tcpdump和windump
Tcpdump简介 tcpdump命令是一款sniffer工具,它可以打印所有经过网络接口的数据包的头信息, tcpdump,就是:dump the traffic on a network,根据使用 ...
- idou老师教你学Istio 24:如何在Istio使用Prometheus进行监控
使用Prometheus进行监控是Istio提供的监控能力之一.Istio提供丰富的监控能力,为网格中的服务收集遥测数据.Mixer是负责提供策略控制和遥测收集的Istio组件. Istio通过Mix ...
- 【jmeter】无GUI界面,命令行运行测试脚本
一.应用场景 1.无需交互界面或受环境限制(linux text model) 2.远程或分布式执行 3.持续集成,通过shell脚本或批处理命令均可执行,生成的测试结果可被报表生成模块直接使用,便于 ...
- python_json模块和pickle模块
json 优点:所有语言通用:缺点:只能序列化基本的数据类型list/dict/int... json格式中,字符串必须是双引号,字符都是小写. 序列化: import json v = [12,3, ...