This article examines the causes of Java OutOfMemoryError in a distributed backend service, analyzes MyBatis-related memory leaks, demonstrates a reproducible scenario with large SQL concatenations and multithreading, and offers practical mitigation strategies to prevent heap and metaspace overflow.
This article provides a comprehensive, step‑by‑step analysis of MyBatis’s overall architecture, covering its core features, three‑layer design, configuration parsing, proxy generation, SQL execution process, and the underlying components that enable seamless Java‑to‑SQL mapping.
This article explains the core principles and multiple usage patterns of MyBatis PageHelper for pagination, demonstrates code examples, details its internal ThreadLocal and interceptor mechanisms, and highlights common pitfalls with safe versus unsafe practices to ensure reliable data retrieval.
The article recounts three real‑world pagination bugs—batch‑processing loops, misuse of MyBatis PageHelper, and nondeterministic results from identical ORDER BY values—explaining why they occur, how they manifest in production, and concrete fixes to avoid data loss or endless loops.
This article describes a unified, configurable data‑permission framework built on RBAC, detailing its architecture, rule definition, integration workflow, Java SDK implementation, and practical examples to achieve flexible, low‑coupling access control across multiple backend systems.
This article explains how JDBC evolves into MyBatis, why JDBC should be wrapped into a persistence framework, and examines MyBatis's architecture, initialization process, and design‑pattern usage, providing code examples and optimization steps for developers.
This article analyzes the MyBatis source code, illustrating how it applies a variety of design patterns—including Factory, Singleton, Builder, Adapter, Proxy, Composite, Decorator, Template, Strategy, and Iterator—to solve complex architectural challenges and improve modularity, extensibility, and maintainability.
This tutorial provides an in‑depth guide to Spring Boot covering core concepts such as project setup, configuration files, logging frameworks, MVC architecture, CRUD examples, error handling, embedded servlet containers, Docker integration, JDBC/MyBatis/JPA data access, startup process, and how to create custom starter modules.
This article presents a typical requirement to calculate count, minimum, maximum, and average scores for three subjects in a student_score table, demonstrates how to fulfill it using raw SQL, then shows step‑by‑step implementations with Fluent MyBatis, native MyBatis XML, and MyBatis‑Plus code generation, and finally compares the three approaches highlighting their pros and cons.
This article demonstrates how to implement a statistical query on a student_score table using three ORM frameworks—Fluent Mybatis, native Mybatis, and Mybatis‑Plus—showing code examples, configuration steps, and a side‑by‑side comparison of their ease of use and generated code.
This tutorial demonstrates how to integrate a custom MyBatis TypeHandler in a Spring Boot 2.6.12 application to automatically encrypt sensitive fields before persisting them to MySQL and decrypt them on retrieval, covering dependencies, configuration, entity definition, encryption utilities, mapper XML, and test cases.
This article reviews the various design patterns—creational, structural, and behavioral—employed within MyBatis's source code, illustrating each pattern with diagrams and explaining their roles in simplifying factory creation, singleton configuration, builders, adapters, proxies, decorators, templates, strategies, and iterators.
This article demonstrates multiple approaches—including direct MyBatis batch, per‑row insertion, and JDBC batch processing—to insert 300,000 user records into a MySQL table, compares their performance, and provides practical optimization tips such as batch size tuning, waiting intervals, index handling, and connection‑pool configuration.
This article explains how MyBatis binds mapper interfaces to XML files, details the complete SQL execution flow—including mapper retrieval, statement preparation, parameter handling, and result mapping—and demonstrates how to create custom TypeHandlers for both parameter setting and result set processing.
This article provides a comprehensive guide to MyBatis dynamic SQL, explaining its features, common XML tags such as if, where, set, choose, trim, foreach, include, and sql, and demonstrates how to implement CRUD operations, conditional queries, batch processing, and association mappings with clear code examples.
This article explains what SQL injection is, demonstrates a vulnerable example, and presents four practical defenses for Java applications—including PreparedStatement, MyBatis #{} placeholders, request‑parameter filtering, and Nginx reverse‑proxy rules—complete with code snippets and configuration details.
This article walks through the step‑by‑step JDBC query process, explains why wrapping JDBC in a framework like MyBatis is beneficial, analyzes MyBatis’s core components and execution flow, and presents five practical optimizations—from connection pooling to dynamic SQL and result caching—to improve Java backend performance.
This article explains how Lombok’s unconventional getter/setter naming for fields with a lowercase‑first, uppercase‑second pattern causes MyBatis to map enum properties as null, and how the @Accessor(chain=true) annotation in EasyExcel triggers cglib reflection issues, then provides practical workarounds for both problems.
The article examines how MyBatis applies a variety of creational, structural, and behavioral design patterns—such as Factory, Singleton, Builder, Adapter, Proxy, Composite, Decorator, Template, Strategy, and Iterator—to decouple its over‑twenty‑thousand‑line codebase, improve modularity, and handle complex ORM tasks efficiently.
This article examines the ClassCastException that occurs when 100 threads concurrently query MyBatis using a shared SqlSession, analyzes the root cause in DefaultSqlSession and BaseExecutor, and explains how Spring Boot’s MyBatis integration employs SqlSessionTemplate, ThreadLocal binding, and transaction management to guarantee thread‑safe SqlSession usage.
This article explains how JDBC operations evolve into the MyBatis persistence framework, covering JDBC's seven-step query process, MyBatis's design components, initialization workflow, builder patterns, and includes practical Java code examples for each stage.
This article explains MyBatis dynamic SQL, its nine XML tags, execution principle, and how to use if, where, set, choose, trim, foreach, sql, include, and association mappings for flexible query building, batch operations, and one‑to‑many, many‑to‑one, and many‑to‑many relationships.
This article demonstrates how to insert 300,000 rows into a MySQL table efficiently by defining entity, mapper and configuration files, comparing direct batch insertion, row‑by‑row insertion, and optimized batch strategies with MyBatis and JDBC, and summarizing performance results and best‑practice tips.
This article walks through the step‑by‑step evolution from raw JDBC queries to the MyBatis persistence layer, highlighting why JDBC should be wrapped, the design improvements MyBatis introduces, core components, execution flow, initialization mechanisms, and related design patterns, all illustrated with code snippets and diagrams.
This article presents a systematic performance test of inserting massive data into MySQL, comparing three strategies—MyBatis lightweight insertion, direct JDBC (with and without transactions), and JDBC batch processing—showing how transaction handling and batch execution dramatically affect insertion speed.
This article explains how JDBC evolves into MyBatis, detailing the seven-step JDBC query process, the motivations for encapsulating JDBC, MyBatis architecture, core components, initialization mechanisms, design patterns, and code examples, while offering optimization strategies for connection handling, SQL management, and result mapping.
This guide walks through setting up a Spring Boot 2.4.12 project with JDK 1.8, Oracle, and two data sources—master and slave—covering Maven dependencies, application.yml settings, custom property classes, HikariDataSource beans, JPA EntityManagerFactory, MyBatis SqlSessionFactory, mapper scanning, and testing entity creation to verify successful configuration.
The SQLE 2.2309.0-pre1 release introduces downloadable scan task reports, eight new MySQL audit rules, and expands MyBatis scanning to all supported data source types, while providing comprehensive project overview, full release information, and links to documentation and demos.
This article examines whether adding the always‑true condition WHERE 1=1 in MySQL queries prevents index usage, by comparing EXPLAIN plans for queries with and without the clause and proposing a cleaner MyBatis mapping approach.
This guide explains why the MyBatis Log Plugin is useful for converting MyBatis console SQL logs into ready‑to‑run statements, and provides step‑by‑step instructions for installing the plugin in IntelliJ IDEA, activating it, and configuring log levels for proper operation.
This article explains how to insert 300,000 rows into a MySQL table efficiently by defining a User entity, configuring MyBatis mappers, and comparing three approaches—direct bulk insert, per‑row loop insert, and batch insert with configurable batch sizes—while also providing JDBC equivalents and performance tips.
This article demonstrates multiple ways to insert 300,000 rows into a MySQL table using MyBatis and JDBC, compares batch, loop, and single‑record approaches, analyzes execution time and resource usage, and provides practical optimization tips for high‑throughput data loading.
During a traffic peak the CPU surged and thread dumps revealed many MySQL Statement Cancellation Timer threads; this article analyzes the root cause in the MySQL driver, Druid pool and MyBatis configuration, and provides concrete steps to eliminate the unwanted timer threads.
SQL injection is a critical web security flaw where unsanitized user input can alter database queries, and this article explains its mechanics, demonstrates vulnerable Java code, and outlines four prevention methods—PreparedStatement, MyBatis #{}, request parameter filtering, and Nginx reverse‑proxy rules—complete with code examples.
This article explains how to protect user‑sensitive information such as ID numbers and phone numbers by encrypting data before insertion and decrypting after retrieval using a MyBatis interceptor that leverages custom annotations, AES utilities, and minimal code intrusion.
This article demonstrates how to accelerate a one‑million‑row database query by adding indexes and using a multithreaded Java Spring controller with MyBatis, showing code examples, performance tests, and suggestions for further optimization.
This article explains MyBatis dynamic SQL, its powerful XML tags, how to build conditional queries, batch operations, and association mappings, providing clear code examples and best‑practice tips for Java backend developers.
The article compares JPA and MyBatis in Chinese software projects, argues that JPA excels when solid OOP design and domain modeling are prioritized while MyBatis shines in data‑driven or fast‑delivery scenarios, and illustrates the discussion with Java code examples and design‑pattern reminders.
This article introduces a MyBatis‑based SQL analysis component that detects and prevents slow queries before they impact production by performing real‑time EXPLAIN analysis, offering optimization suggestions, and enabling dynamic SQL replacement, while detailing its design, configuration, performance testing, and practical advantages.
This article explains how to use MyBatis streaming queries via the Cursor interface, showing configuration, code examples, batch processing techniques, practical use cases, and important precautions to efficiently handle large result sets without exhausting JVM memory.
This article demonstrates multiple approaches—including MyBatis batch inserts, per‑row inserts, and JDBC batch processing—to efficiently load 300,000 user records into a MySQL table, compares their performance, and provides practical optimization tips such as batch size, waiting intervals, and index handling.
This article compares JPA and MyBatis, discusses when each framework shines, explores design‑driven development approaches, and highlights common pitfalls such as oversized services, neglected OOP principles, and the importance of proper data modeling for large‑scale Java backend projects.
This article explains MyBatis dynamic SQL, its execution principle, and the nine core XML tags (if, where, set, choose, trim, foreach, sql, include, resultMap) with detailed examples of CRUD operations, conditional queries, batch processing, and association mappings for Java backend development.
This article introduces a Java‑based private cinema reservation system built on Spring Boot and MyBatis, outlines its core technologies, provides step‑by‑step deployment instructions, and details all functional URLs and the source‑code download method.
Under high concurrency, improper configuration of MyBatis parameterType and resultType can lead to thread BLOCKED states due to repeated TypeHandler cache misses, and this article analyzes the root causes, demonstrates debugging steps, and provides recommendations to avoid such performance bottlenecks.
This tutorial explains how to use MyBatis interceptor mechanisms to dynamically modify SQL statements at runtime in a Spring Boot application, covering interceptor types, implementation steps, configuration, core code, testing, and common use cases such as SQL monitoring, pagination, and data permission filtering.
This article investigates the root causes of frequent OutOfMemoryError incidents in a distributed Java backend, explains how MyBatis and DruidDataSource can exhaust heap and metaspace, demonstrates a reproducible test with JVM options and multithreading, and offers practical mitigation strategies.
This article explains three MySQL pagination methods—simple LIMIT syntax, MyBatis RowBounds logical pagination, and the powerful MyBatis-PageHelper plugin—detailing their usage, configuration, code examples, and performance considerations to help Java developers efficiently handle large data sets.
When interviewers ask how to insert a thousand rows with MyBatis, the answer isn’t just a simple Java for‑loop; you need to consider batch processing, disable autocommit, and understand MyBatis’s limits to choose the most reliable and performant approach.
This article demonstrates how to leverage MyBatis interceptor mechanism in a Spring Boot 3 application to dynamically modify SQL statements, showing step‑by‑step implementation, configuration, core code, testing, and common use cases such as SQL monitoring, pagination, and data permission filtering.
MyBatis-Flex is a lightweight, high‑performance extension to MyBatis that adds full CRUD, pagination, multi‑table and batch operations while preserving all MyBatis features, supports multi‑datasource relations, recursive queries, and provides extensive annotations such as @Relation for flexible data mapping, with recent v1.4.9 updates and bug fixes.
This article explains how MyBatis first‑level (session) and second‑level (cross‑session) caches work, the conditions required for them to function, common pitfalls when integrating with SpringBoot, and step‑by‑step instructions to enable and safely use second‑level caching in real projects.
This article explains how to smoothly migrate a legacy single‑database system to a sharded architecture by using dual‑write, mapping‑key routing, custom transaction handling, and offline/real‑time diff checks, while detailing the underlying MyBatis integration and component‑based design.
This article explains MyBatis streaming queries, introduces the Cursor interface and its key methods, shows how to implement streaming with code examples, discusses suitable application scenarios, and outlines important considerations for efficient, low‑memory data processing in Java backend systems.
The article explains MyBatis first‑level and second‑level caching mechanisms, their activation conditions, integration pitfalls with Spring Boot, and how to enable and use them safely, including configuration steps, code examples, and warnings about hidden risks of second‑level cache.
This article provides a comprehensive guide to MyBatis dynamic SQL, demonstrating how to use if, choose, trim, foreach, and bind tags for conditional queries, updates, inserts, batch operations, and database‑agnostic expressions, complete with Maven project setup, SQL scripts, and test cases.
This article introduces MyBatis streaming query using the Cursor interface, explains its core methods, demonstrates implementation with code examples, discusses suitable application scenarios, and outlines important considerations for efficient and safe large‑scale data processing in Java backend development.
This article introduces MyBatis streaming queries, explains the Cursor interface and its methods, provides step‑by‑step code examples for configuration and implementation, discusses practical application scenarios such as large‑scale data processing, and highlights important considerations for efficient and safe usage.
This article describes the challenges of migrating a long‑running monolithic database to a sharded architecture, presents a two‑stage smooth migration strategy using double‑write, diff verification, and mapping‑key techniques, and details the componentized design, core implementation, and configuration of a reusable sharding framework built on MyBatis and Spring.
This article explains how to design and implement a business operation logging feature using Spring AOP in a Spring Boot project, covering requirement analysis, anti‑pattern pitfalls, AOP design, environment and dependency setup, database schema, annotation and aspect code, and testing procedures.
This article explores how Lombok’s auto‑generated getter/setter methods can conflict with MyBatis property naming conventions and cause null values, examines the underlying reflection logic in MyBatis, and also reveals why the @Accessor(chain=true) annotation disrupts EasyExcel’s CGLIB‑based mapping, offering practical solutions.
This article explains how Lombok's generated getter and setter method names can conflict with MyBatis property resolution and cause issues when using EasyExcel's @Accessor(chain=true) annotation, and provides detailed code examples and solutions to resolve these incompatibilities.
This article demonstrates multiple strategies for inserting 300,000 rows into a MySQL table using MyBatis and JDBC, comparing batch‑insert, single‑row loops, packet size limits, transaction handling, and performance tuning techniques such as batch size, waiting intervals, and index management.
This guide explains how to use MyBatis dynamic SQL tags such as foreach, if, where, choose, trim, and selectKey, providing practical examples for conditional queries, batch inserts, updates, and reusable SQL fragments to write flexible and error‑free MySQL statements in Java applications.
This article explains the concept and purpose of Spring Boot starters, compares mybatis‑spring with mybatis‑spring‑boot‑starter through code examples, and details how the starter simplifies MyBatis integration by handling dependencies, configuration files, auto‑configuration, and mapper scanning for Java backend projects.
This article explains how to export large MySQL datasets in SpringBoot by streaming data directly to CSV, avoiding full‑memory loads that cause OutOfMemoryError, and provides complete JPA and MyBatis implementations, performance testing, and practical code examples for production use.
This article reviews several Java technologies that have become obsolete or less relevant—such as JSP, Struts, Hibernate, Applet, Swing, JDBC, and XML—explaining why newcomers can safely ignore them and focus on modern alternatives like Spring MVC, MyBatis, and deep Servlet knowledge.
This article provides a detailed tutorial on setting up MyBatis Generator in a Spring Boot application, covering configuration file placement, XML adjustments, Maven dependencies, execution steps, and the resulting model, mapper, and XML files with full code examples.
The article explains that MyBatis PageHelper performs an extra full‑table count query causing pagination to take over eight seconds on a 10,000‑row table, analyzes the root cause, and provides a concrete solution by customizing the count SQL with a _COUNT method and optimized mapper definitions.
This article explains how to handle large‑scale data inserts with multithreading in Spring Boot using MyBatis, why the @Transactional annotation fails across threads, and how to achieve reliable all‑or‑nothing rollbacks by manually managing transactions with SqlSession and thread pools.
The article explains three ways to perform batch inserts with MyBatis—ordinary single-row inserts, foreach‑based bulk inserts, and ExecutorType.BATCH—analyzes their SQL logs, performance bottlenecks, MySQL limits, and provides practical recommendations for large‑scale data insertion.
This article explains why MyBatis foreach‑based batch inserts become extremely slow with thousands of rows, demonstrates how the generated giant SQL statement hurts performance, and shows how switching to ExecutorType.BATCH or limiting rows per INSERT dramatically reduces insertion time.
This article explains how to export tens of millions of rows from MySQL using Spring Boot by streaming data with JPA or MyBatis, avoiding OutOfMemoryError, switching to CSV format, and provides complete code examples, performance comparison, and tips for generating test data.
This guide demonstrates how to integrate the MybatisX IDEA plugin with a Spring Boot project, covering database setup, Maven dependency configuration, plugin installation, connection testing, code generation, and sample controller implementation to accelerate MyBatis and MyBatis-Plus development.
This article explains XSS attack types, SQL injection risks, and provides practical SpringBoot filter implementations with MyBatis prepared statements and custom deserializers to sanitize request parameters, JSON bodies, and prevent malicious script and database attacks.
The article explains how to process massive MySQL data sets—covering data migration, export, and batch handling—by comparing regular pagination, streaming queries using server‑side cursors, and cursor‑based fetchSize techniques, and provides concrete MyBatis code examples for each approach.
This article explains why MyBatis foreach‑based batch inserts become extremely slow with thousands of rows, analyzes the underlying SQL generation and parsing costs, and demonstrates how using ExecutorType.BATCH or limiting rows per INSERT can reduce a 14‑minute operation to under two seconds.
The article explains how to prevent OutOfMemoryError when exporting massive MySQL datasets by streaming records with JPA or MyBatis, writing them directly to CSV files, and demonstrates significant memory savings compared to traditional batch export methods.
This article introduces FastMyBatis—a lightweight, zero‑configuration MyBatis extension for Spring Boot—covering its core principles, Maven setup, sample CRUD controller, service and mapper implementations, a comprehensive list of mapper methods, Query object usage examples, and links to the open‑source repository.
This article examines how MyBatis leverages around ten core design patterns—including Factory, Singleton, Builder, Adapter, Proxy, Composite, Decorator, Template, Strategy, and Iterator—to decouple complex scenarios, improve modularity, and streamline ORM operations within its extensive codebase.
To efficiently process massive MySQL result sets without exhausting JVM memory, this article explains three query strategies—regular pagination, stream-based retrieval using MyBatis cursors, and cursor-based fetching with configurable fetchSize—detailing their implementations, advantages, and practical considerations.
Processing massive datasets in MySQL can cause OOM and slow performance; this article explains when to use regular pagination, streaming queries, and cursor-based fetching, compares their trade‑offs, and provides MyBatis code examples with @Options and @ResultType to handle millions of rows efficiently.
This article presents a practical guide to implementing monthly sharding for high‑volume billing data using MySQL stored procedures, dynamic table creation, and SpringBoot‑MyBatis integration, covering schema design, code examples, and query strategies for inserting, retrieving, and managing partitioned tables.
This article presents five common batch‑insert approaches for MyBatis and MyBatis‑Plus—including a for‑loop, manual batch commit, collection‑based batch, saveBatch, and InsertBatchSomeColumn—provides complete code examples, configuration steps, and measured execution times to help Java backend developers choose the most efficient method.
This article provides a comprehensive guide to MyBatis dynamic SQL tags—including foreach, if, choose, trim, selectKey, and related constructs—explaining their attributes, usage scenarios, and offering detailed Java and XML code examples for building flexible and error‑free database queries.
This article explains how to overcome export failures for reports exceeding ten thousand rows by using MyBatis streaming reads with JDBC, detailing the three read modes, required MyBatis configurations, and providing complete controller, service, DAO, and mapper code examples.
This article provides a comprehensive guide on using Spring Batch within a Spring Boot application, covering CSV and database data sources, detailed configuration beans, custom readers, processors, writers, listeners, validation, and execution via a REST controller, along with practical troubleshooting tips.
This article shares common pitfalls of Java candidates, emphasizes building a solid Java foundation, and provides a curated collection of over 100 interview questions covering Spring, Redis, MyBatis, and multithreading, with a QR code for accessing the full answer set.
This article provides a comprehensive guide to MyBatis, covering its basic concepts, Maven dependency configuration, XML setup, entity and mapper definitions, execution flow using dynamic proxies, and a custom lightweight framework implementation with full Java code examples.
This article explains how to overcome export failures caused by large data volumes in a legacy Java system by switching from default full-result JDBC reads to a forward‑only streaming approach using MyBatis, detailing environment setup, configuration changes, and complete code examples for controller, service, DAO, and mapper layers.
This article presents a detailed overview of five commonly used MyBatis and MyBatis-Plus batch insertion methods, including code examples, configuration steps, and performance measurements for inserting ten thousand records, helping developers choose the most efficient approach for large‑scale data insertion in Java backend projects.
This article provides a comprehensive step‑by‑step guide on integrating Spring Batch with Spring Boot, covering configuration, entity and mapper definitions, job, step, reader, processor, writer implementations, database setup, error handling, and execution via a REST controller, complete with code examples.
This article explains how to replace repetitive try‑catch blocks in Java Spring applications with a unified exception handling strategy that leverages @ControllerAdvice, custom Assert utilities, enum‑based error codes, and standardized response objects to improve code readability, maintainability, and internationalisation.
This article evaluates the efficiency of inserting massive datasets into MySQL using three Java strategies—MyBatis without transactions, direct JDBC with and without transactions, and JDBC batch processing—by measuring execution times for millions of records and analyzing the impact of transactions and batching.
This article presents and compares five practical batch‑insert methods for MyBatis and MyBatis‑Plus, covering preparation steps, code implementations, configuration details, and performance results, helping developers choose the most efficient approach for inserting large volumes of data in Java backend projects.
This article presents a full‑stack student management system built with Vue on the front end and SpringBoot + MyBatis on the back end, detailing project introduction, deployment steps, technology stacks, core functionalities, database design, and source code acquisition.
This article evaluates the efficiency of inserting massive synthetic person data into MySQL using Java, comparing MyBatis, plain JDBC (with and without transactions), and JDBC batch processing, and presents detailed timing results for each strategy across tens of millions of rows.
This post shares a free, extensive compilation of interview questions and detailed explanations covering Java fundamentals, multithreading, Spring framework, Redis, MyBatis and other backend technologies, encouraging systematic preparation and offering a QR‑code method to obtain the full document.
This article reviews the Java ecosystem, explains criteria for deeming technologies outdated, and advises developers to drop JSP, Struts, Hibernate, Applet, Swing, JDBC, and XML while focusing on mastering Servlets, Spring MVC, and lightweight ORM tools like MyBatis.