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.
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.
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.
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.
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.
