在写javaweb项目的时候发现报的这个错误:

org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='brandName', mode=IN, javaType=class java.lang.Integer, 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.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')

开始认为是sql问题仔细检查并运行了我的sql

    <update id="updateBrand" parameterType="java.lang.Integer">update tb_brand set brand_name = #{brandName},company_name = #    {companyName},ordered=#{ordered},description=#{description},status=#{status} where id=#{id};</update>

发现sql并没有问题,sql解析参数数量和匹配的参数数量是一致的,后端servlet用debug进入后发现确实是在执行sql的时候报错,那么问题在哪里呢?

再看因为自己写的是修改,所以实际上parameterType的参数可以不传,但不知道为什么因为我在写mapper接口的时候自动生成的语句设置了parameterType参数为java.lang.Integer所以在执行sql语句开始报500错误

解决办法:

    <update id="updateBrand" parameterType="com.sujju.brand.pojo.Brand">update tb_brand set brand_name = #{brandName},company_name = #{companyName},ordered=#{ordered},description=#{description},status=#{status} where id=#{id};</update>

将parameterType设置为自己实体类的路径或者把parameterType删除

最后项目运行就没报错了

org.apache.ibatis.type.TypeException: Could not set parameters for mapping报错相关推荐

  1. nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping

    今天mybatis报了个错误 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type ...

  2. MyBatis中PersistenceException:Error querying database. Cause: org.apache.ibatis.type.TypeException:

    org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: org.apache.ibatis ...

  3. ssm中报错: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type a

    错误:Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ...

  4. org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常

    异常: 二月 06, 2018 3:33:44 下午 org.apache.catalina.core.StandardContext listenerStart 严重: Exception send ...

  5. 【Mybatis】报错:org.apache.ibatis.type.TypeException: The alias 'Collection' is already mapp

    jar包有同类名,冲突了.加个别名就好了 import org.apache.ibatis.type.Alias; @Alias("tb_collection") public c ...

  6. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException:

    解决: 1 在SQL语句中使用#{name,jdbcType=VARCHAR} ​指定JDBC类型 错误的: 修改后的:

  7. Mybatis使用之 Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias‘User’

    注意错误提示,是在UserMapper.xml中出现的问题,自己检查后并没有发现问题. 从Mybatis官网文档中,找到select标签的下面两个属性的区别,将resultType换成resultMa ...

  8. org.apache.ibatis.type.TypeException: The alias ‘XXXX‘ is already mapped to the value ‘XXXX‘ 问题解决

    1. 问题原因 同一个boot项目下 不同包内存在相同的类名导致这个错误 2.解决办法 找到对应的类添加 @Alias("XXX") 注解,其中xxx 是来区分两个类的不同标识

  9. org.apache.ibatis.type.TypeException: Could not resolve type alias ''

    我这里错是因为xml文件resultMap类型错了 就是这里类找不到

最新文章

  1. 【PHPWord】插入Excel对象
  2. python拿什么做可视化界面好-手把手教你用Python做个可视化的“剪刀石头布”小游戏...
  3. python程序实例电话本-Python示例
  4. python多线程下载m3u8文件,python 实现多线程下载m3u8格式视频并使用fmmpeg合并
  5. Nginx + PHP CGI的fix_pathinfo安全漏洞
  6. zigbee 频谱波段
  7. 改变openssl的环境变量linux,ECS Linux 安装配置openssl的具体过程
  8. ios 数组中的字典排序_利用数组和字典,实现按指定规则的排序
  9. 创建IOS应用程序通用下的Setting以及读取方式
  10. Qt4_写HTTP客户端
  11. Asp.Net MVC 3【Filters(过滤器)】
  12. LiquidCrystal-I2C
  13. 大数据私房菜--Hadoop完全分布式安装
  14. java类 家族成员 姓氏_极其罕见的四大姓氏,若你还姓这个,恭喜你,你的家族大有来头!...
  15. Java开发环境及其特点
  16. 消除switch/case语句,不破坏代码的封闭性,使程序结构更符合面向对象思想(二)
  17. Win10怎么安装旧版组件DirectPlay?
  18. 【mac】macos苹果系统终端如何进入ROOT及退出问题
  19. 1亿条数据批量插入 MySQL,哪种方式最快?
  20. 单源最短路径 dijkstra

热门文章

  1. mac安装git系列报错解决
  2. 短视频伪原创最新方法?6年老司机手把手教你如何运营
  3. 利用AOP进行简单的性能监控及用户行为审计
  4. HUAWEI P20为你打造智慧云上生活
  5. 聪明听话还支持全球80多家音乐台,这样的音响你想要么
  6. Spine 多个动作连播时是否要K初始帧
  7. matlab 分水岭函数,【填空题】用来实现分水岭算法的MATLAB函数是 ____________
  8. oracle goldengate学习笔记,Oracle GoldenGate 学习教程
  9. Search(搜索法)
  10. 简述python爬虫原理_python 爬虫原理