当前位置:网站首页>mapper.xml文件中的注释
mapper.xml文件中的注释
2022-07-05 14:49:00 【蓝天⊙白云】
mapper.xml文件中的注释
注释方式
在mapper.xml文件中,注释方式为<!--existence of query content-->,直接采用Java代码方式的注释/*existence of query content*/会报错,尤其是在SQL语句中出现这种注释方式时。
‘无效的列索引’bug和解决
昨天在导入数据时需要对数据进行验证,在mapper文件中对表中数据进行查询,将作废sql注释时选择了Java方式,此时会报错。
<select id="getSeqNameCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
SELECT COUNT(*) COUN FROM tablename A
WHERE A.id=#id# and A.name=#name#
/*SELECT * FROM tablename A WHERE A.id=#id# and A.name=#name#*/
</select>
在解析时由于会将参数位置解析为占位符‘?’,所以此时以下的sql会在后台解析成如下,但是传入的参数只有两个,所以这个时候会报 “Caused by: java.sql.SQLException: 无效的列索引”,因为传入的参数和占位符数量不等。
SELECT COUNT(*) COUN FROM tablename A WHERE A.id=? and A.name=?
/*SELECT * FROM tablename A WHERE A.id=? and A.name=?/
总结
1、mapper.xml文件中注释方式为<!--existence of query content-->;
2、 “Caused by: java.sql.SQLException: 无效的列索引”错误一般由sql语句中占位符引起:
1传入参数数量不等与占位符的数量;
2SQL语句中的占位符?是中文版;
3SQL语句中的占位符?被放在字符串内;
边栏推荐
- Dark horse programmer - software testing -10 stage 2-linux and database -44-57 why learn database, description of database classification relational database, description of Navicat operation data, de
- How to choose the appropriate certificate brand when applying for code signing certificate?
- Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
- JMeter performance test: serveragent resource monitoring
- Can I pass the PMP Exam in 20 days?
- Thymeleaf uses background custom tool classes to process text
- 你童年的快乐,都是被它承包了
- 做研究无人咨询、与学生不交心,UNC助理教授两年教职挣扎史
- I collect multiple Oracle tables at the same time. After collecting for a while, I will report that Oracle's OGA memory is exceeded. Have you encountered it?
- 手写promise与async await
猜你喜欢

Interpretation of Apache linkage parameters in computing middleware

Machine learning notes - gray wolf optimization

1330:【例8.3】最少步数

Coding devsecops helps financial enterprises run out of digital acceleration

当代人的水焦虑:好水究竟在哪里?

Dark horse programmer - software testing -10 stage 2-linux and database -44-57 why learn database, description of database classification relational database, description of Navicat operation data, de

Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment

【jvm】运算指令

Ecotone technology has passed ISO27001 and iso21434 safety management system certification

百亿按摩仪蓝海,难出巨头
随机推荐
Using tensorboard to visualize the training process in pytoch
【NVMe2.0b 14-9】NVMe SR-IOV
Two Bi development, more than 3000 reports? How to do it?
CPU设计实战-第四章实践任务三用前递技术解决相关引发的冲突
MySQL之CRUD
选择排序和冒泡排序
计算中间件 Apache Linkis参数解读
想进阿里必须啃透的12道MySQL面试题
手写promise与async await
机器学习框架简述
可视化任务编排&拖拉拽 | Scaleph 基于 Apache SeaTunnel的数据集成
How to paste the contents copied by the computer into mobaxterm? How to copy and paste
Easyocr character recognition
用 Go 跑的更快:使用 Golang 为机器学习服务
Photoshop plug-in action related concepts actionlist actiondescriptor actionlist action execution load call delete PS plug-in development
be careful! Software supply chain security challenges continue to escalate
机器学习笔记 - 灰狼优化
Selection and use of bceloss, crossentropyloss, sigmoid, etc. in pytorch classification
anaconda使用中科大源
Thymeleaf uses background custom tool classes to process text