• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Try setting a different JdbcType for this parameter or a different configuration property

武飞扬头像
晓梦初醒p
帮助1

  1.  
    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='auditStatus', mode=IN, javaType=class java.lang.Integer, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException
  2.  
    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='auditStatus', mode=IN, javaType=class java.lang.Integer, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException
  3.  
        at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
  4.  
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
  5.  
        at com.sun.proxy.$Proxy26.selectOne(Unknown Source)
  6.  
        at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159)
  7.  
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
  8.  
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:93)
  9.  
        at com.sun.proxy.$Proxy85.getProcModel(Unknown Source)
  10.  
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  11.  
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  12.  
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  13.  
        at java.lang.reflect.Method.invoke(Method.java:498)
  14.  
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
  15.  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
  16.  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  17.  
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
  18.  
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
  19.  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  20.  
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
  21.  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  22.  
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
  23.  
        at com.sun.proxy.$Proxy86.getProcModel(Unknown Source)
  24.  
        at com.ftcs.userinfo.service.service.impl.ExitCompanyAuditServiceImpl.getProcModel(ExitCompanyAuditServiceImpl.java:101)
  25.  
        at com.ftcs.userinfo.service.service.impl.ExitCompanyAuditServiceImpl$$FastClassBySpringCGLIB$$336c7faf.invoke(<generated>)
  26.  
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
  27.  
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750)
  28.  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  29.  
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
  30.  
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
  31.  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  32.  
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
  33.  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  34.  
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
  35.  
        at com.ftcs.userinfo.service.service.impl.ExitCompanyAuditServiceImpl$$EnhancerBySpringCGLIB$$fe4fb185.getProcModel(<generated>)
  36.  
        at org.apache.dubbo.common.bytecode.Wrapper39.invokeMethod(Wrapper39.java)
  37.  
        at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)
  38.  
        at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:84)
  39.  
        at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:56)
  40.  
        at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
  41.  
        at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:77)
  42.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  43.  
        at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:46)
  44.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  45.  
        at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:91)
  46.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  47.  
        at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:52)
  48.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  49.  
        at com.alibaba.dubbo.rpc.Invoker$CompatibleInvoker.invoke(Invoker.java:55)
  50.  
        at com.ftcs.commons.dubbo.trace.filter.TraceProviderFilter.invoke(TraceProviderFilter.java:60)
  51.  
        at com.alibaba.dubbo.rpc.Filter.invoke(Filter.java:29)
  52.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  53.  
        at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:192)
  54.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  55.  
        at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
  56.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  57.  
        at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:41)
  58.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  59.  
        at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:129)
  60.  
        at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61)
  61.  
        at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:148)
  62.  
        at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:100)
  63.  
        at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:175)
  64.  
        at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)
  65.  
        at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)
  66.  
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  67.  
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  68.  
        at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41)
  69.  
        at java.lang.Thread.run(Thread.java:748)
  70.  
    Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='auditStatus', mode=IN, javaType=class java.lang.Integer, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException
  71.  
        at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:89)
  72.  
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:94)
  73.  
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:64)
  74.  
        at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:88)
  75.  
        at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
  76.  
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
  77.  
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
  78.  
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:136)
  79.  
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
  80.  
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
  81.  
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
  82.  
        at sun.reflect.GeneratedMethodAccessor253.invoke(Unknown Source)
  83.  
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  84.  
        at java.lang.reflect.Method.invoke(Method.java:498)
  85.  
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
  86.  
        ... 65 more
  87.  
    Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException
  88.  
        at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:71)
  89.  
        at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:87)
  90.  
        ... 79 more
  91.  
    Caused by: java.lang.ClassCastException
学新通

上面的报错提示重点看下面

 Could not set parameters for mapping: ParameterMapping{property='auditStatus', mode=IN, javaType=class java.lang.Integer, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='auditStatus', mode=IN, javaType=class java.lang.Integer, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException

这边是sql

  1.  
    <select id="getProcModel" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  2.  
    select
  3.  
    <include refid="Base_Column_List" />
  4.  
    from exit_company_audit
  5.  
    where is_deleted = 0
  6.  
    and user_id = #{userId, jdbcType=INTEGER}
  7.  
    and audit_status = #{auditStatus, jdbcType=VARCHAR}
  8.  
    </select>

这个提示就很明显了,属性auditStatus设置了一个和其本身数据类型不一致的数据,那么可能的情况有哪些?

1:java中写的dao中auditStatus的数据类型和sql中auditStatus的数据类型不一致

解决方案:修改成一致或者直接删掉sql中auditStatus的jdbcType

2:parameterType="java.lang.Integer"中表示参数是Integer,但是你有两个参数,auditStatus是varchar的.

解决方案:删除paramType这个参数

3:还有就是sql中auditStatus的和java中auditStatus的名称不一样(这个不是我这边存在的问题)

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfhkchi
系列文章
更多 icon
同类精品
更多 icon
继续加载