分页接口count语句参数丢失Parameter index out of range (2 > number of parameters, which is 1)

Blade 未结 2 62
sdiCb
sdiCb 1天前

一、该问题的重现步骤是什么?

1. 日志生成的count语句:

Execute SQL : select count(*) as total from smarts_user_collection t1, smarts_course t2, ( select course_id, count(*) as lesson_count, sum(duration) as total_duration from smarts_course_lesson where is_deleted = 0 and tenant_id = '000000' group by course_id ) stat where t1.target_id = t2.id and t2.id = stat.course_id and t1.is_deleted = 0 and t1.user_id = 2049049889082535937 and t1.tenant_id = '000000' and t2.tenant_id = '000000'



xml sql内容:

image.png

image.png


userId 和targetType都是有值的

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?

为什么生成的sql参数丢了targetType

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

springboot 版本,4.8.0.RELEASE   windows本地

四、请提供详细的错误堆栈信息,这很重要。

org.mybatis.spring.MyBatisSystemException: 

### Error querying database.  Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='userCollectionDTO.targetType', 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 #2 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 #2 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).

五、若有更多详细信息,请在下面提供。

2条回答
  •  admin
    admin (楼主)
    1天前

    跑个原版的不含bladex的springboot工程,复现下这个代码逻辑,看看在没有bladex的情况下,你的这套代码是否能正常读取到参数

提交回复