Mybatis报错___入参异常导致

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException:
Could not set parameters for mapping: ParameterMapping
{property='docNo', 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 null for parameter #1 with JdbcType OTHER .
Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property.
Cause: java.sql.SQLException: 无效的列类型: 1111
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
    at com.sun.proxy.$Proxy116.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
    at com.sun.proxy.$Proxy122.getDeptNameByDocNoBydocNo(Unknown Source)
    at com.group.emr.heren.dao.oracle.PatientDao.setHospitalPatient(PatientDao.java:233)

------------------------------------------------------------------------------

上面是自己项目中碰到的问题;

原因:

DefaultParameterHandler类在解析参数的时候,无法解析参数类型,指定默认的类型OTHER.

解决办法:

解决办法:

 在insert或update语句中,增加jdbcType指定字段的类型

如:

  

  insert into t_yp_province

  (fid,fname,fnumber,fsimpleName,fdescription,fcreateTime,flastUpdateTime,fdirect)

  values

  ( #{id,jdbcType=VARCHAR},

   #{name,jdbcType=VARCHAR},

   #{number,jdbcType=VARCHAR},

   #{simpleName,jdbcType=VARCHAR},

   #{description,jdbcType=VARCHAR},

   #{createTime,jdbcType=DATE},

   #{lastUpdateTime,jdbcType=DATE},

   #{direct,jdbcType=NUMERIC}

  )  

  ]]>

 ;

 

转自:https://www.cnblogs.com/havery/articles/4025879.html    并结合自己碰到的

你可能感兴趣的:(Java)