This article introduces dynamic SQL techniques for Spring Boot 3, compares JPA and MyBatis implementations, and demonstrates how the powerful jpa-search-helper library simplifies complex queries with both map‑based and JSON‑based modes, including pagination and sorting examples.
This article explains how to build a SpringBoot‑MyBatis interceptor that captures SQL execution, constructs a hierarchical call tree, and visualizes it with D3.js, providing real‑time performance monitoring and debugging for complex business systems.
This article presents a SpringBoot‑MyBatis solution that captures SQL execution via an interceptor, builds a hierarchical call tree, visualizes it with D3.js, and provides REST APIs for real‑time monitoring, performance statistics, and configuration, helping developers debug complex queries and identify slow SQL.
This article demonstrates how to build a SpringBoot‑based SQL call‑tree visualization system using a MyBatis interceptor, D3.js front‑end, and thread‑local context to capture, organize, display and analyze SQL execution hierarchies, performance metrics and slow‑SQL detection for complex business applications.
The MyBatis SQL Viewer plugin streamlines MyBatis development by converting XML to real SQL, offering parameter mocking, compliance and index checks, execution, stress testing, and both MyBatis and non‑MyBatis modes, all without repeatedly restarting the application.
This article analyzes why MyBatis foreach batch inserts become extremely slow with thousands of rows, explains the underlying parsing and PreparedStatement overhead, and presents faster alternatives such as ExecutorType.BATCH, Java‑side loops, and MyBatis Dynamic SQL batch support.
This article explains why using MyBatis foreach for bulk inserts can cause severe performance degradation, demonstrates the underlying parsing overhead, and shows how switching to ExecutorType.BATCH or limiting batch sizes to 20‑50 rows dramatically speeds up insert operations.
This article introduces the MyBatis‑SQL‑Viewer plugin, which transforms MyBatis XML into executable SQL, offers parameter mocking, syntax and compliance checks, index analysis, stress testing, and scanning features, dramatically simplifying CRUD development and improving SQL quality without restarting the application.
This article explains how oversized database query results can cause JVM heap spikes, frequent Full GC, or OOM crashes in Java services, and demonstrates a non‑intrusive MyBatis interceptor solution that monitors, grades, and blocks risky queries while exposing Prometheus metrics for proactive alerting and capacity planning.
This article explains how Spring 3.0's pure annotation mode simplifies bean configuration, demonstrates replacing XML with @Component and @Configuration, covers bean scopes, dependency injection techniques like @Autowired, @Qualifier, @Value, and shows seamless integration of Spring with MyBatis for data access.
This article explains why the @Transactional annotation fails in multithreaded Spring batch insert scenarios, demonstrates the problem with code examples, and shows how to use SqlSession for manual commit and rollback to guarantee atomicity across all threads.
This article introduces MybatisPlusPro, an extension of MyBatis‑Plus that automates controller‑level CRUD, pagination, dynamic queries, data auditing, permission control, and performance optimizations, showing how developers can dramatically reduce code and improve efficiency in Java backend projects.
This article systematically compares six MyBatis batch‑update approaches—including simple for‑loop, foreach XML, CASE WHEN, ON DUPLICATE KEY UPDATE, REPLACE INTO, and MyBatis‑Plus—by presenting concrete code, execution‑time measurements on 10 000 rows, and analysis of I/O, SQL parsing, scalability, and database compatibility, ultimately recommending the most performant and maintainable method for different scenarios.
This article provides a concise overview of the most commonly used annotations in MyBatis, Spring MVC, Spring, SpringBoot, and Lombok, explaining their purposes and typical usage scenarios for Java backend development.
This article explains why using MyBatis foreach for bulk inserts can cause severe performance degradation, analyzes the underlying parsing and executor issues, and provides practical solutions such as using ExecutorType.BATCH and limiting batch sizes to achieve fast, reliable batch insertion.
This article explains what streaming queries are, why MyBatis's Cursor requires an open database connection, and presents three practical solutions—using SqlSessionFactory, TransactionTemplate, or @Transactional—to correctly implement MyBatis streaming queries in Spring applications while avoiding common pitfalls.
This article walks through the complete process of designing, configuring, and coding a sharding solution for loan and repayment tables—including database basics, historical data migration, backend query refactoring, a three‑write strategy, scheduled consistency checks, and full SpringBoot/ShardingSphere implementation details.
This article demystifies MyBatis’s caching system, explaining the architecture of first- and second-level caches, how SqlSession, Executor and Cache interact, key generation rules, configuration steps, and best practices for achieving optimal database query performance.
This article explains how to implement a lightweight MyBatis interceptor that annotates SQL statements with their mapper ID and execution stack, enabling developers to quickly locate performance bottlenecks during high‑traffic events, and also shows an AspectJ alternative for non‑MyBatis projects.
This article explains why MyBatis's default StdOutImpl logging, which relies on System.out.println, blocks threads and creates severe concurrency bottlenecks, and demonstrates how to replace it with asynchronous logging implementations like Slf4jImpl, configure log levels, and even create custom Log classes for optimal performance.
This tutorial walks you through building a Spring Boot project that uses the easy-data-scope library to inject dynamic SQL for fine‑grained data permissions, covering database setup, Maven dependencies, core annotations, custom rule implementation, and practical query examples.
This article explains how to use SQL coloring in MyBatis by implementing a lightweight interceptor or an AspectJ weave to annotate each SELECT statement with its mapper ID and execution stack, enabling rapid identification of performance bottlenecks during high‑traffic events.
This article introduces a lightweight SQL‑coloring technique for MyBatis that annotates each executed query with its mapper ID and call‑stack, enabling developers to pinpoint performance bottlenecks instantly without hunting through multiple code paths, and provides both MyBatis interceptor and AspectJ weaving implementations.
This article demonstrates how to use Java 8's Function and SFunction functional interfaces together with lambda expressions to abstract and reuse data‑validation logic, dramatically reducing repetitive code, improving readability, and enabling flexible, generic validation across various backend entities.
This article presents a real‑world case study of a high‑traffic backend API that originally took 30 seconds to process over two million records, detailing problem diagnosis, SQL and Java code analysis, and a series of optimizations—including SQL rewrites, database‑side aggregation, and Caffeine caching—that ultimately cut the response time to under one second.
This article explains how to configure MyBatis for dynamic SQL using XML mapper files and annotation-based methods, provides step‑by‑step code examples, and compares the advantages and disadvantages of each approach to help developers choose the best solution for their projects.
This tutorial explains how to set up and use the easy-data-scope library in a Spring Boot project to implement dynamic SQL data‑permission rules with MyBatis, covering database preparation, Maven dependencies, core annotations, configuration files, and example queries for various permission scenarios.
This article introduces easy-data-scope, a lightweight Java library that enables dynamic SQL‑based data permission control for MyBatis, MyBatis‑Plus, and MyBatis‑Flex, showing how to set up the project, configure dependencies, define annotations, and apply various permission scenarios with code examples.
This tutorial walks through setting up the easy-data-scope library in a Spring Boot project, configuring the database and dependencies, defining DataScopeInfo, using the @DataScope annotation, and demonstrating various permission scenarios such as filtering by ID, age, merging conditions, and custom templates.
The article describes how to enforce environment‑based data isolation in a shared database by adding an env column, using a MyBatis interceptor to inject and filter this field at runtime, and employing a custom @InvokeChainSkipEnvRule annotation with AOP to selectively bypass the rule, keeping existing code untouched.
This guide demonstrates how to integrate the easy-data-scope library into a Spring Boot project to implement dynamic, annotation‑driven SQL data permissions with MyBatis, covering project setup, dependency configuration, core interfaces, annotation options, and practical query examples.
This article explains how to create custom MyBatis TypeHandler classes to automatically convert Java objects—such as JSON strings and enum codes—to appropriate JDBC types, simplifying data persistence in Spring Boot applications and improving code maintainability.
This article describes how to achieve multi‑environment data isolation in a Java backend by adding an env field to tables, using a MyBatis interceptor with JSqlParser to rewrite SQL, and applying custom annotations and AOP to control environment‑specific logic while preserving existing business code.
This article reviews common Java backend technologies, explains why JSP, Struts, Hibernate and several legacy tools are no longer worth learning, and highlights the essential concepts—especially deep mastery of Servlets—that modern Java developers should focus on in 2024.
This article explains a low‑intrusion data‑permission design for backend micro‑services, detailing resource and value‑rule definitions, RBAC modeling, MyBatis SQL interception implementation, Redis‑based permission retrieval, and Spring Boot auto‑configuration for easy enablement in production.
This article analyzes unexpected behaviors caused by PageHelper in a Java backend project, such as duplicate user registration, limited query results, and password‑reset errors, and explains how ThreadLocal pagination parameters, startPage(), and cleanup mechanisms lead to these problems while offering practical debugging tips.
This article walks through why repetitive CRUD code wastes development time, reviews existing generators like MyBatis‑Generator and MyBatis‑Plus, and then demonstrates step‑by‑step how to create a custom Java code generator using Freemarker, Maven, and SpringBoot, complete with template and demo code.
This article explains MyBatis's two‑level caching mechanism, detailing how first‑level session cache works, why it often fails in Spring Boot without transactions, how to enable and configure second‑level cache, and the potential pitfalls of cache inconsistency across mapper namespaces.
This article details the end‑to‑end design, configuration, and code implementation of a sharding solution for loan and repayment tables, covering database schema changes, historical data migration, dynamic synchronization switches, transaction handling, and practical pitfalls when using Spring Boot 3 with ShardingSphere.
This article provides a comprehensive guide to MyBatis dynamic SQL tags—including foreach, if, choose, trim, selectKey, and reusable SQL fragments—explaining their attributes, usage patterns, and code examples to help developers write cleaner, more reliable XML mappers and avoid common pitfalls.
This article describes a practical approach to achieve environment-based data isolation in a Java application by adding an 'env' field to tables, using a custom MyBatis interceptor to rewrite SQL, and defining annotations with AOP to control environment filtering, while discussing challenges and refactoring considerations.
This article explains the purpose of using the always‑true condition “WHERE 1=1” in MyBatis SQL mappings, demonstrates through EXPLAIN queries that it does not prevent index usage, and recommends a cleaner MyBatis syntax that lets MySQL’s optimizer remove the redundant condition.
The article explains why data masking is essential for protecting sensitive information, then details three implementation methods—SQL, Java (with open‑source plugins), and the MyBatis‑Mate‑Sensitive‑Jackson ORM extension—comparing their principles, code examples, advantages, limitations, performance, suitable scenarios, and cost considerations.
This article describes a lightweight, non‑intrusive MyBatis plugin that adds identifiable coloring comments to SQL statements—embedding statementId, pFinderId, and optional custom data—to simplify SQL source tracing, improve slow‑SQL analysis, and support SELECT, INSERT, UPDATE, DELETE operations with minimal performance overhead.
This article provides a comprehensive, English-language walkthrough of MyBatis's four core components—Executor, StatementHandler, ParameterHandler, and ResultSetHandler—explaining their interfaces, default implementations, key methods, and how they collaborate to translate Java objects into SQL statements and process query results.
The article explains why data desensitization is essential for enterprises, classifies common masking techniques, and provides concrete implementation guides for database, log, and output level masking in Java applications using MyBatis plugins and Fastjson filters, complete with sample code and configuration.
This article examines the challenges of locating and diagnosing SQL statements in large systems and introduces a lightweight, non‑intrusive MyBatis plugin that injects color‑marking metadata into SELECT, INSERT, UPDATE and DELETE queries, enabling rapid business source identification and enhanced debugging.
This article explains how to achieve data isolation in a Spring Boot application by creating a MyBatis interceptor that uses JSqlParser to parse and modify SQL statements at the prepare stage, covering tool introductions, dependency setup, interceptor code, testing examples, and the reasoning behind intercepting the prepare method.
This article announces a Spring Boot 3 case collection with 100 permanent examples and then provides a comprehensive guide on recording SQL statements in Spring Boot applications via JDBC, JPA, MyBatis and the datasource‑proxy library, including configuration snippets, code samples and visual output illustrations.
This article walks through creating a fully automated Spring Boot and MyBatis code generator using Freemarker templates, detailing each step from extracting table metadata to generating DAO, service, controller, and entity classes, and shows how a single-table CRUD can be produced in seconds.
This article explains the concept and benefits of logical deletion, then demonstrates how to implement it in Spring Boot 3 using JPA annotations like @SQLDelete and @SoftDelete, and MyBatis‑Plus configuration, complete with code examples and SQL output.
The article describes a real‑world Oracle ORA‑000060 deadlock encountered during bulk updates of user records, explains the root cause of unsorted duplicate user_id entries across parallel threads, and outlines practical solutions such as sorting input files and adjusting transaction order, illustrated with MyBatis code and DeepSeek insights.
The article describes a production deadlock (ORA-000060) caused by unsorted, duplicate user_id rows in a file processed in parallel batch updates, shows MyBatis XML code, illustrates conflicting thread execution, and provides practical solutions such as sorting the input and deduplicating records.
This article explains how to achieve data isolation in a Spring Boot application by using a MyBatis interceptor that leverages JSqlParser to parse and modify SQL statements at the StatementHandler.prepare stage, covering tool introductions, dependency setup, interceptor implementation, testing examples, and the rationale behind intercepting the prepare method.
The article explains how inserts work in relational databases, why fixed‑size pages and batch transactions dramatically reduce I/O and lock contention, and provides practical MyBatis guidelines—using the foreach tag, ExecutorType.BATCH, and an appropriate batchSize while estimating memory and disk limits to choose an optimal batch size and commit only once.
This article walks senior Java developers through MyBatis fundamentals, core components, result mapping, the trade‑offs between #{} and ${}, dynamic SQL, second‑level caching, batch inserts, plugin creation, thread‑safety concerns, and concrete interview‑question solutions, all illustrated with real code snippets and performance numbers.
This article demonstrates how to achieve data isolation in a Spring Boot application by creating a MyBatis interceptor that modifies SQL statements using JSqlParser, covering tool introductions, dependency setup, interceptor implementation, testing for SELECT/INSERT/UPDATE/DELETE, and the rationale for intercepting the prepare method.
The article introduces Cool Request, an IDEA plugin that now supports a Trace feature for measuring execution time of any method, automatic MyBatis function tracing, customizable duration coloring, and script-based environment manipulation, complete with usage examples and code snippets.
Based on 20 years of Java experience, this article evaluates Java technologies like JSP, Struts, Hibernate, and Servlet against practical use, depth of understanding, and interview relevance, recommending which to drop, which to master, and highlighting alternatives such as Spring MVC and MyBatis.
This article explains why developers often insert the always‑true condition 1=1 in SQL, examines its potential performance and readability drawbacks, and demonstrates cleaner alternatives using MyBatis dynamic tags and Entity Framework to build conditional queries without unnecessary predicates.
The article investigates a MyBatis batch‑insert job that consumes excessive CPU and takes 14 minutes, explains why the foreach‑generated giant INSERT statement is inefficient, and demonstrates how switching to ExecutorType.BATCH or MyBatis dynamic‑SQL batch support reduces the runtime to under two seconds.
This article presents a real‑world case study of a high‑concurrency data‑processing interface whose response time was reduced from 30 seconds to under one second by diagnosing SQL bottlenecks, applying PostgreSQL array aggregation, moving logic to the database, and introducing Caffeine caching, with detailed code examples and performance analysis.
The article reviews a Java veteran's 20‑year experience to identify backend technologies such as JSP, Struts, Hibernate, Servlet, Applet, Swing, JDBC and XML that are now outdated or less essential, and recommends focusing on Spring MVC, MyBatis and a deep understanding of Servlets for modern development.
This article explains how to implement dynamic database switching in MyBatis by intercepting and modifying SQL statements to prepend database names to table names, using JSqlParser and MyBatis interceptors.
This article explains how to query multiple identical databases under a single data source by intercepting MyBatis SqlSource, using JSqlParser to prepend the appropriate database name to table references, and applying the decorator pattern for seamless dynamic database switching.
This article explains how to integrate Spring Boot with MyBatis, configure a single Druid data source, implement a dynamic routing data source for multiple databases, and use custom annotations and AOP to switch databases at runtime, including full code examples and transaction management.
This article explains why data desensitization is essential for modern enterprises, compares masking, obfuscation and encryption techniques, and provides step‑by‑step implementations for database, log, and output layers using MyBatis interceptors, Fastjson filters, and Spring MVC configuration.
The article introduces the Cool Request IDEA plugin, explains its tracing capabilities for arbitrary packages, automatic MyBatis function monitoring, customizable timing colors, script-based environment manipulation, and provides a Java code example for handling responses, highlighting its usefulness for backend developers.
When processing massive MySQL result sets, loading all rows into JVM memory can cause OOM and slow performance, so this guide compares three approaches—regular pagination, streaming queries using server-side cursors, and cursor‑based fetchSize control—detailing their implementations, MyBatis configurations, and trade‑offs.
This article walks through a real‑world case where swapping MyBatis for MyBatis‑Plus introduced a LocalDateTime conversion error, explains the root cause in MyBatis version changes and JDBC driver support, and shares subsequent bug fixes and lessons on cautious component upgrades.
Because MyBatis reads a primitive boolean field directly when no getter exists, the default false value is bound as 0, causing an unexpected zero in the MySQL tinyint column; changing the field to the Boolean wrapper (initialized to true) or fixing the update logic resolves the issue.
When migrating an old Java project from MyBatis 3.5.0 to MyBatis‑Plus 3.1.1, a test failed with “Conversion not supported for type java.time.LocalDateTime” because MyBatis 3.5.1 stopped handling Java 8 time types and the existing mysql‑connector‑java 5.1.26 driver lacked support, which was resolved by upgrading the connector to version 5.1.37 or later, highlighting the need for thorough compatibility testing during framework upgrades.
The article explains how to design low‑intrusion data‑permission mechanisms for backend micro‑services by defining resources and value‑rules, storing permission data in Redis, intercepting MyBatis SQL execution, and enabling the whole solution with a Spring Boot auto‑configuration annotation.
The article introduces the latest Cool Request IDEA plugin update, detailing its Trace capability for method execution timing, selective MyBatis function monitoring, customizable slow‑method highlighting, and scripting support for headers and JSON parsing, all illustrated with Java code examples.
The MyBatis SQL Viewer plugin transforms MyBatis XML into executable SQL, provides mock parameters, checks SQL standards and indexes, supports data mocking, performance testing, and offers both MyBatis and non‑MyBatis modes, all without restarting the application.
This article demonstrates how to wrap the EasyExcel library in a Spring Boot + MyBatis‑Plus project, providing a unified component that simplifies Excel import and export through concise annotations, reusable service methods, and customizable converters while addressing common pitfalls such as date handling and template support.
This article introduces an open‑source tool that automatically generates all Java business code—including entity classes, DAO interfaces, SQL statements, service implementations, and controllers—for new database tables, dramatically reducing the hours spent on repetitive CRUD scaffolding.
The MyBatis‑SQL‑Viewer plugin transforms MyBatis XML into executable SQL, offers mock data generation, SQL syntax and compliance checks, index analysis, performance stress testing, and seamless navigation between mapper interfaces and XML files, all without restarting the application.
This article introduces the Fluent Mybatis ORM framework, explains its design advantages, demonstrates how to implement a complex student‑score aggregation query using Fluent Mybatis, native MyBatis and MyBatis‑Plus, and provides end‑to‑end code examples for entity generation, configuration, and CRUD testing.
This article explains why using MyBatis foreach for bulk inserts can cause severe performance degradation, analyzes the underlying cost of large prepared statements, and demonstrates how switching to ExecutorType.BATCH or limiting each INSERT to 20‑50 rows dramatically improves insertion speed.
The MyBatis SQL Viewer plugin transforms MyBatis XML into executable SQL, provides mock parameters, syntax and compliance checks, index analysis, performance testing, data mocking, and comprehensive UI features, enabling developers to validate, benchmark, and manage SQL without restarting the application.
This article explains how Spring 3.0's pure annotation mode simplifies bean configuration, demonstrates using @Component, @Scope, @Autowired, @Qualifier, @Value, and @PropertySource for dependency injection and property loading, and shows step‑by‑step integration of MyBatis with Spring, including required dependencies and configuration classes.
This article provides a detailed walkthrough of JD’s open‑source sql‑analysis component, dissecting its eight functional modules, MyBatis interceptor flow, SQL extraction logic, query‑plan analysis, rule‑based scoring, and output strategies, while highlighting design patterns and potential extension points for developers.
This article explains the concept of short‑URL redirection, its benefits, and provides a complete SpringBoot implementation—including database schema, entity, DAO, service, controller, and testing code—to convert long links into short, trackable links and handle redirects.
This tutorial explains how to design a MySQL table for hot‑search records, generate Java entity and mapper classes using MyBatis Generator, create unique IDs for each entry, and implement scheduled Java crawlers for Douyin and Baidu hot‑search data that persist the results via Spring‑Boot services.
This article introduces JD’s open‑source sql‑analysis component, explains its design based on a MyBatis interceptor, demonstrates how it analyzes SQL execution plans with Explain and a rule engine to warn about potential slow queries, and shows step‑by‑step usage and its advantages for early detection and rapid hot‑swap remediation.
This article demonstrates how to use Fluent MyBatis, native MyBatis, and MyBatis‑Plus to implement a complex statistical query on a student_score table, compares the amount of code and effort required for each approach, and provides code generation settings for both frameworks.
This article explains how MySQL writes data to cache before flushing to disk, compares single‑row versus batch inserts, discusses how hardware limits, transaction size, and lock contention affect performance, and shows how to estimate an optimal batch size with concrete calculations and MyBatis examples.
The article introduces Fluent Mybatis, a compile‑time code‑generating ORM that merges Mybatis‑Plus, Dynamic SQL and JPA features, eliminates XML mappers, offers a fluent, type‑safe Java API, and demonstrates through concise examples how it reduces boilerplate compared with native Mybatis and Mybatis‑Plus.
This article explores four common batch‑update techniques in MyBatis, compares their performance, shows how to configure Druid and Spring Boot to allow multi‑statement execution, and provides practical code examples and configuration tips for reliable large‑scale data updates.
This article explains MyBatis plugins’ core capabilities—SQL rewriting, logging, performance monitoring, transaction enhancement, and result handling—detailing their interception points, the Java dynamic‑proxy implementation, a complete pagination plugin example, typical application scenarios, and practical best‑practice recommendations for developers.
This article explains how to configure XXL‑JOB with a sharding‑broadcast strategy in a SpringBoot application, use ID modulo hashing to partition large tables, implement the task with XxlJobHelper, write MyBatis sharding SQL, and verify correct parallel processing through detailed logs.
This article introduces MyBatis‑Mate, an enterprise‑grade MyBatis extension that provides sharding, data auditing, sensitive‑word filtering, field encryption, dictionary binding, dynamic DDL maintenance, data‑scope permissions and performance monitoring, complete with practical code examples and configuration guidance.
This article details a real‑world performance case where a high‑concurrency interface processing over two million rows was diagnosed and optimized through SQL tuning, Java code refactoring, and caching, ultimately reducing response time from 30 seconds to under 0.8 seconds.
This article explains how to correctly manage transactions across multiple threads in a Spring application by using manual SqlSession control, providing utility methods for list partitioning, thread‑pool configuration, and example code that demonstrates both failing and successful transaction scenarios.
This article introduces ShardingJDBC, a Java middleware that simplifies sharding, read/write separation, and distributed transactions, and provides a step‑by‑step Spring Boot example with configuration, code snippets, and verification of its core features.
Learn how to seamlessly integrate the open‑source p6spy tool into a Spring Boot 3.2.5 application to automatically log SQL statements, measure execution times, customize logging formats, and fine‑tune database performance using both MyBatis and JPA examples.
The article analyzes a production out‑of‑memory crash triggered by a pagination bug that misused the OFFSET parameter, explains why the error escaped testing and code review, and presents corrected pagination techniques for Oracle, MySQL and MyBatis to prevent similar failures.
The article introduces mybatis-mate, an enterprise‑grade MyBatis module that supports sharding, multi‑datasource, data auditing, field encryption, sensitive‑data masking, automatic DDL maintenance, performance logging, and fine‑grained data‑scope control, providing code examples and configuration guidelines for Spring Boot projects.