MyBatis reports an error: Could not set parameters for mapping: ParameterMapping{property='category
I just started learning mybatis and kept reporting the following errors when updating
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).
After carefully reviewing the relevant documents, because I wrote the sql statement in the configuration xml file wrong, the following is the error code
update product_category set category_name="#{categoryName}",category_type="#{categoryType}" where category_id="#{categoryId}"
Double quotes are added to the parameter and should be removed
update product_category set category_name=#{categoryName},category_type=#{categoryType} where category_id=#{categoryId}
Run successfully!
2019-03-0612: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-0612:25:49.561 DEBUG 1215---[main] c.i.s.mapper.ProductCategoryMapper.save :==>Parameters:111(String),92(Integer),1(Integer)2019-03-0612:25:49.566 DEBUG 1215---[main] c.i.s. mapper.ProductCategoryMapper.save :<==Updates:1
0 Comments