报错信息:
nested exception is org.apache.ibatis.binding.BindingException: Parameter 'VARCHAR' not found. Available parameters are [list, param1] org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'VARCHAR' not found. Available parameters are [list, param1] at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) ~[mybatis-spring-2.0.1.jar:2.0.1] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) ~[mybatis-spring-2.0.1.jar:2.0.1] at com.sun.proxy.$Proxy166.update(Unknown Source) ~[?:?] at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294) ~[mybatis-spring-2.0.1.jar:2.0.1] at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:65) ~[mybatis-plus-core-3.4.2.jar:3.4.2]
对应的代码:
<update id="updatePayStatusByList"> <foreach collection="list" index="index" item="item"> update emp_fertility_infos <set> <if test="item.id != null"> pay_common_id = #{item.id,jdbcType=INTEGER} </if> </set> where id in (${item.correlateId,jdbcType=VARCHAR}); </foreach> </update>
修改方法:
<update id="updatePayStatusByList"> <foreach collection="list" index="index" item="item"> update emp_fertility_infos <set> <if test="item.id != null"> pay_common_id = #{item.id,jdbcType=INTEGER} </if> </set> where id in (${item.correlateId}); </foreach> </update>
注: ${} 是直接引用值得,不需要声明。
Mybatis中什么时候应该声明jdbcType?
当Mybatis不能自动识别你传入对象的类型时。比如使用 #{}。
标签:Available,VARCHAR,parameters,spring,mybatis,org,2.0,id From: https://www.cnblogs.com/wang188/p/16899067.html