开发者社区> 问答> 正文

通用Mapper插入时处理Null字段有什么好办法:配置报错 

c.z.f.m.s.b.DefaultPublicServiceProcessor - nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='wayBillId', 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 #10 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='wayBillId', 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 #10 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型     at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:76) ~[mybatis-spring-1.2.4.jar:1.2.4]     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:421) ~[mybatis-spring-1.2.4.jar:1.2.4]     at com.sun.proxy.$Proxy35.insert(Unknown Source) ~[na:na]     at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:254) ~[mybatis-spring-1.2.4.jar:1.2.4]     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:52) ~[mybatis-3.3.1.jar:3.3.1]     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) ~[mybatis-3.3.1.jar:3.3.1]     at com.sun.proxy.$Proxy39.insert(Unknown Source) ~[na:na]     at ltl.test.service.FirstService.processRequest(FirstService.java:61) ~[classes/:na]     at ltl.test.service.FirstService.processRequest(FirstService.java:17) ~[classes/:na]     at com.zhy.framework.micro.service.biz

展开
收起
kun坤 2020-06-02 15:04:00 782 0
1 条回答
写回答
取消 提交回答
  • 设置默认值,或者对实体的get方法进行去null处理######Mybatis 有一个动态sql, 比如 <if test ==null>  这里可以处理你的null</if> 不知道符合你的问题么

    2020-06-02 15:04:08
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载