mybatis:Could not set parameters for mapping: ParameterMapping


错误信息:

Could not set parameters for mapping: ParameterMapping{property='goodsImgId', 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 #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).

  

sql语句:

@Insert("INSERT INTO goodsimg(goodsImgId,goodsImgName) VALUE ('#{goodsImgId}','#{goodsImgName}');")

  

解决方法:

方法一:注释问题,无注释,排除
方法二:添加类型,#{goodsImgId,jdbcType=VARCHAR},无用
方法三:错误原因,手贱给参数添加单引号

正确:@Insert("INSERT INTO goodsimg(goodsImgId,goodsImgName) VALUE (#{goodsImgId},#{goodsImgName});")
错误:@Insert("INSERT INTO goodsimg(goodsImgId,goodsImgName) VALUE ('#{goodsImgId}','#{goodsImgName}');")

  

ps:正常的sql添加语句时,也要添加单引号,所以之前测试sql语句时,测试不出错误,手贱啊。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM