1、问题描述
mybatis plus连接oracle执行sql报错:
服务异常,请稍后再试: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_item_0.scsj', mode=IN, javaType=class java.time.LocalDateTime, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #7 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111
2、原因
mybatis plus执行的sql的字段中存在null值,导致oracle无法判断数据类型
3、解决方案
在yml中添加如下配置,添加配置后,空值不会保存为null字符串依然是空值
mybatis-plus:
configuration:
#mybatis-plus发送null给oracle是会报错,所以增加此参数
jdbc-type-for-null: 'null'
4、指定字段解决方案(感谢CunWaiQiShiXuDa提供的方案)
在字段上增加@TableField(jdbcType=),可以解决mybatis-plus3.1.2版本连接oracle,更新字段为NUll报错的问题