当前位置:网站首页>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语句中的占位符?被放在字符串内;
边栏推荐
- Reconnaissance des caractères easycr
- Topology可视化绘图引擎
- PostgreSQL 13 installation
- Change multiple file names with one click
- NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
- FR练习题目---简单题
- 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
- 社区团购撤城“后遗症”
- 【jvm】运算指令
- 做研究无人咨询、与学生不交心,UNC助理教授两年教职挣扎史
猜你喜欢
Microframe technology won the "cloud tripod Award" at the global Cloud Computing Conference!
How to paste the contents copied by the computer into mobaxterm? How to copy and paste
Drive brushless DC motor based on Ti drv10970
计算中间件 Apache Linkis参数解读
【NVMe2.0b 14-9】NVMe SR-IOV
Under the crisis of enterprise development, is digital transformation the future savior of enterprises
危机重重下的企业发展,数字化转型到底是不是企业未来救星
Machine learning notes - gray wolf optimization
FR练习题目---简单题
[JVM] operation instruction
随机推荐
Topology可视化绘图引擎
Change multiple file names with one click
Photoshop插件-动作相关概念-ActionList-ActionDescriptor-ActionList-动作执行加载调用删除-PS插件开发
启牛学堂班主任给的证券账户安全吗?能开户吗?
Cartoon: programmers don't repair computers!
[12 classic written questions of array and advanced pointer] these questions meet all your illusions about array and pointer, come on!
js亮瞎你眼的日期选择器
Two Bi development, more than 3000 reports? How to do it?
【jvm】运算指令
市值蒸发超百亿美元,“全球IoT云平台第一股”赴港求生
Jmeter性能测试:ServerAgent资源监控
1330:【例8.3】最少步数
GPS原始坐标转百度地图坐标(纯C代码)
[recruitment position] infrastructure software developer
MySQL之CRUD
CPU设计实战-第四章实践任务三用前递技术解决相关引发的冲突
计算中间件 Apache Linkis参数解读
mysql8.0JSON_ Instructions for using contains
Mongdb learning notes
【数组和进阶指针经典笔试题12道】这些题,满足你对数组和指针的所有幻想,come on !