MyBatis通用mapper插入,更新null值问题

2022-04-13 16:03:46 浏览数 (1)

MyBatis通用mapper插入,更新null值问题

  • Mybatis通用Mapper updateByPrimarykey()和insert()方法报错,提示jdbctype错误。
代码语言:javascript复制
Exception in thread “main” org.springframework.jdbc.UncategorizedSQLException: Error setting null for parameter #6 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111 
  • springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)
代码语言:javascript复制
  @Bean
    public ConfigurationCustomizer configurationCustomizer(){
        return new MybatisPlusCustomizers();
    }

    class MybatisPlusCustomizers implements ConfigurationCustomizer {

        @Override
        public void customize(org.apache.ibatis.session.Configuration configuration) {
            configuration.setJdbcTypeForNull(JdbcType.NULL);
        }
    }

0 人点赞