Why Replacing MyBatis with MyBatis-Plus Can Break Your Java App—and How to Fix It
This article walks through replacing MyBatis with MyBatis-Plus in a Spring Boot project, explains the LocalDateTime conversion error caused by MyBatis 3.5.1 and an outdated MySQL connector, and shows how upgrading the connector resolves the issue while highlighting the risks of component upgrades.
MyBatis Replaced by MyBatis-Plus
Background
An old project uses MySQL 5.7, MyBatis 3.5.0, and mysql-connector-java 5.1.26.
Why replace
A new developer found MyBatis cumbersome and decided to switch to MyBatis-Plus for simpler code.
Migration steps
Created table tbl_order with two rows, then switched the ORM to MyBatis-Plus 3.1.1 while keeping the same connector version.
Running com.qsl.OrderTest#orderListAllTest produced the exception “Conversion not supported for type java.time.LocalDateTime”.
Root cause analysis
The exception originates from MyBatis 3.5.1, which stopped handling LocalDateTime, LocalDate, and LocalTime conversions and delegated them to the JDBC driver. The driver version 5.1.26 does not support these types.
Upgrading mysql-connector-java to 5.1.37 adds support for the three Java time types, eliminating the error.
Further issues
After the upgrade, inserting a row with a NULL timestamp caused a NullPointerException. The stack trace showed that getTimestamp(columnIndex) returned NULL. Updating the driver to 5.1.42 resolved the problem.
Lesson
Component upgrades can introduce subtle incompatibilities. Always verify the compatibility of ORM libraries, JDBC drivers, and Java time types, and perform thorough testing after any version change.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
