您现在的位置是:网站首页>JavaJava
MyBatis报错:Could not set parameters for mapping: ParameterMapping{property='categoryName', mode=IN, j
左鹏03-06 12:26:36【Java】13,863人已围观
简介刚开始学习mybatis在update时一直报以下错误 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='categoryName', mode=IN, javaType=class java.la
刚开始学习mybatis在update时一直报以下错误
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='categoryName', mode=IN, javaType=class java.lang.String, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 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 (1 > number of parameters, which is 0).
经过仔细查看相关文档是,因为我配置xml文件的sql语句写错了,以下为错误代码
update product_category set category_name="#{categoryName}",category_type="#{categoryType}" where category_id="#{categoryId}"
在参数上多加了双引号,应删除
update product_category set category_name=#{categoryName},category_type=#{categoryType} where category_id=#{categoryId}
运行成功!
2019-03-06 12:25:49.514 DEBUG 1215 --- [main] c.i.s.mapper.ProductCategoryMapper.save : ==> Preparing: update product_category set category_name=?,category_type=? where category_id=?
2019-03-06 12:25:49.561 DEBUG 1215 --- [main] c.i.s.mapper.ProductCategoryMapper.save : ==> Parameters: 111(String), 92(Integer), 1(Integer)
2019-03-06 12:25:49.566 DEBUG 1215 --- [main] c.i.s.mapper.ProductCategoryMapper.save : <== Updates: 1
相关文章
点击排行
本栏推荐
猜你喜欢
站点信息
- 建站时间:2018-09-18
- 网站程序:Spring Boot
- 主题模板:《今夕何夕》
- 文章统计:104条
- 微信公众号:扫描二维码,关注我们