About the Bug...

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of MyBatis.

  • [x] I have confirmed this bug reproduces without 3rd party extensions (e.g. mybatis-plus).

Database Version

All

JDBC Driver Version

All

Issue Description

The first enum in Java has the ordinal value 0. Instead of mapping the value 0 to the first enum the EnumOrdinalTypeHandler maps to null. Code lines 50 and 59 check if ordinal == null and then return null. That’s definitely wrong.

About your report...

  • [x] I did not use images 🖼️ for showing text information (code, error, etc.).

  • [x] I checked the Preview and my report looks awesome! 👍

Comment From: harawata

Hello @gmixa ,

I assume you are referring to this part of the code.

https://github.com/mybatis/mybatis-3/blob/433e3136df0005365e287a450bb898e8679019dd/src/main/java/org/apache/ibatis/type/EnumOrdinalTypeHandler.java#L49-L52

It returns null when the column is NULL, not zero.

If you still believe there is a bug, please provide a small executable project like these. Be sure to include proper assertions in the test so that we can understand the expected/actual behaviors.

Thank you.