MyBatis在操作Oracle数据库时,插入Null提示无效字
2018-06-26 本文已影响2人
Belmode
这是因为mybatis在解释null默认转换为数据
Other
类型,MySQL认识,但是Oracle不认识,所以报错。
![]()
Caused by: org.apache.ibatis.type.TypeException: Error setting null for parameter #3 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111
两种解决方法
-
在插入语句中的字段的表达式括号内加入jdbc类型
2.在Mybatis全局配置文件中加入setting : jdbcTypeForNull
<settings>
<setting name="jdbcTypeForNull" value="NULL"/>
</settings>