通用Mapper插入时处理Null字段有什么好办法

迷糊涂 发布于 2017/03/02 15:59
阅读 1K+
收藏 0

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

加载中
0
风翔飞
风翔飞

设置默认值,或者对实体的get方法进行去null处理

0
蛐蛐未加V
蛐蛐未加V

Mybatis 有一个动态sql, 比如 <if test ==null>  这里可以处理你的null</if>

不知道符合你的问题么

返回顶部
顶部