Why Replacing MyBatis with MyBatis‑Plus Can Break Your App—and How to Fix It

The article walks through swapping MyBatis for MyBatis‑Plus in a legacy Java project, explains the LocalDateTime conversion error caused by MyBatis 3.5.1 and an outdated MySQL driver, shows how upgrading mysql‑connector‑java resolves the issue, and warns that component upgrades can trigger cascading bugs that require thorough testing.

Top Architect
Top Architect
Top Architect
Why Replacing MyBatis with MyBatis‑Plus Can Break Your App—and How to Fix It

MyBatis to MyBatis‑Plus Migration

An old project uses MySQL 5.7, MyBatis 3.5.0 and mysql‑connector‑java 5.1.26. A new developer wants to replace MyBatis with MyBatis‑Plus to simplify code.

Problem

Running the demo test com.qsl.OrderTest#orderListAllTest after the replacement throws Conversion not supported for type java.time.LocalDateTime.

Root Cause

MyBatis 3.5.1 stopped handling LocalDateTime, LocalDate, and LocalTime conversions internally. The JDBC driver (mysql‑connector‑java 5.1.26) does not support these types, so the conversion fails.

Solution

Upgrade mysql‑connector‑java to version 5.1.37 (or later), which adds support for LocalDateTime, LocalDate, and LocalTime. After the upgrade the test runs successfully and returns correct query results.

Additional Insights

MyBatis 3.5.0 performed the conversion itself; 3.5.1 delegates to the JDBC driver, which explains the new exception. The change is referenced in MyBatis‑Plus issue #1114. Using other connection pools such as Druid may surface different symptoms.

Unrelated Bug‑Fix Story

A separate production incident involved a file‑generation validation bug where the logic incorrectly passed when only one master file existed. After correcting the validation to require all master files, a new exception appeared due to a null timestamp, which was resolved by the same driver upgrade.

Conclusion

Component upgrades can have far‑reaching effects. Avoid unnecessary changes; when changes are unavoidable, perform comprehensive testing to catch hidden incompatibilities.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaBackend DevelopmentmysqlORMmybatis-plus
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

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.