ibatis报错:无效的列索引

本文详细记录了在处理sqlmap-ec-search.xml文件中getNonCarNewEdrBaseInfos方法时遇到的无效的列索引错误。通过一系列排查,最终发现是Java注释方法在SQL代码中使用不当导致的问题。文章分享了解决方案,即更改SQL代码的注释方式,避免类似错误的发生。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误日志如下:

根据日志提示为sqlmap-ec-search.xml文件的getNonCarNewEdrBaseInfos的plyNo处存在问题,找到SQL出错位置,如图:

仔细检查后未发现任何问题,然后换了一个简单的SQL传同样的值测试后没有出现该问题,最后怀疑注释的部分引起的问题,删掉注释的代码后能成功运行未报错,经过亲测发现不能用Java的注释方法注释SQL代码,改为如下方式即可:

不明白为什么注释引起的错误会报出“无效的列索引”错误。真的是细节决定成败!!!

 

 

 

<select id="selectToolChamPassDownList" parameterType="ToolChamPassDown" resultMap="ToolChamPassDownResult"> <include refid="selectToolChamPassDownDetailVo"/> <where> <if test="cham != null and cham != ''"> AND cham LIKE '%' || #{cham} || '%' </if> <if test="chamList != null and chamList.size() > 0"> AND cham IN <foreach item="cham" index="index" collection="chamList" open="(" separator="," close=")"> #{cham} </foreach> </if> <if test="owner != null and owner != ''"> AND owner LIKE '%' || #{owner} || '%' </if> <if test="passDownDesc != null and passDownDesc != ''"> AND pass_down_desc LIKE '%' || #{passDownDesc} || '%' </if> <if test="passDownTime != null"> <choose> <when test="params.exportDays == null"> AND pass_down_time = #{passDownTime} </when> <otherwise> <if test="params.exportDays > 0"> and pass_down_time between to_date(SUBSTR(#{passDownTime},0,18),'yyyy-mm-dd hh24:mi:ss') - (#{params.exportDays} - 1) and to_date(SUBSTR(#{passDownTime},0,18),'yyyy-mm-dd hh24:mi:ss') </if> </otherwise> </choose> </if> <if test="createType != null"> AND create_type = #{createType} </if> <if test="shift != null"> AND shift = #{shift} </if> <if test="capabilityId != null and capabilityId != ''"> AND capability_id = #{capabilityId} </if> </where> ORDER BY sort ASC, cham ASC, pass_down_time </select> 报错:17:04:25.594 [http-nio-8081-exec-2] WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - [logException,208] - Resolved [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='params.exportDays', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #5 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #5 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: 无效列索引]
最新发布
07-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值