当前使用版本(必填,否则不予处理)

com.baomidou mybatis-plus-annotation 3.5.3.1

该问题是如何引起的?(确定最新版也有问题再提!!!)

使用EnumValue注解, 数据库是null的时候, 默认会映射成0的枚举值.

debug发现在MybatisEnumTypeHandler中, ResultSet.getObject返回的是0而不是null. 使用另外一个ResultSet.getObject方法可以返回null.

重现步骤(如果有就写完整)

报错信息

Comment From: eye-gu

我发现这个问题是mysql的驱动导致的, 在8.0.33版本中, ResultSet.getObject(String columnLabel, Class type) 和getObject(String columnLabel)都返回null

Comment From: eye-gu

MyBatis-Plus 使用枚举映射时, 如果数据库为null, 返回的是0值的枚举对象 但是在mp这边, 这个判断我觉得应该修改为或者, value为null或者wasNull为true都应该返回null

Comment From: eye-gu

ResultSetImpl.getObject(), when autoboxing a value of a primitive type retrieved from a column, returned a non-null object when the retrieved value was null. (Bug #29446100, Bug #94533)

https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/news-8-0-17.html