Backend Development 10 min read

Replacing MyBatis with MyBatis‑Plus: Version Compatibility, Debugging, and Lessons Learned

This article walks through the process of swapping MyBatis for MyBatis‑Plus in a legacy Java project, explains why upgrading MyBatis to 3.5.1 triggers a LocalDateTime conversion error, shows how updating mysql‑connector‑java resolves the issue, and shares the broader pitfalls of component upgrades and bug fixes.

Top Architect
Top Architect
Top Architect
Replacing MyBatis with MyBatis‑Plus: Version Compatibility, Debugging, and Lessons Learned

Background: an old project uses MySQL 5.7, MyBatis 3.5.0, and mysql‑connector‑java 5.1.26. A new developer finds MyBatis cumbersome and decides to replace it with MyBatis‑Plus 3.1.1 while keeping the connector version unchanged.

Initial Demo: a simple tbl_order table is created with two rows to illustrate the migration.

Running com.qsl.OrderTest#orderListAllTest after the switch throws an exception: Conversion not supported for type java.time.LocalDateTime . The stack trace points to the JDBC driver, which does not support the new Java 8 date‑time types in version 5.1.26.

Solution Part 1 – Upgrade the JDBC driver: upgrading mysql‑connector‑java to 5.1.37 adds support for LocalDateTime , LocalDate , and LocalTime . After the upgrade the test runs without errors and returns correct results.

Root‑Cause Analysis: MyBatis 3.5.1 stopped handling Java 8 date‑time conversions internally and delegated them to the JDBC driver, which in versions prior to 5.1.37 cannot process those types. Therefore the combination of MyBatis 3.5.1 + MyBatis‑Plus + an old connector caused the failure.

Further Issues – After fixing the conversion problem, a new bug appears when inserting a record with INSERT INTO tbl_order VALUES (3, 'asdfgh', NULL, '2024-02-21 20:01:31.111', '2024-02-21 20:02:56.764'); . The test again fails, this time due to a NullPointerException caused by a null timestamp. The investigation shows that the underlying cause is the same driver limitation, which is finally resolved by upgrading the driver to 5.1.42.

Lesson Learned: component upgrades can have cascading effects; always verify compatibility of all dependent libraries and perform thorough testing before pushing changes to production.

Additional Content: the article also contains several promotional sections advertising ChatGPT services, a knowledge‑sharing community, and related offers. These sections are reproduced verbatim from the original source.

debuggingJavaMySQLORMMyBatis-Plusversion compatibility
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.