This article analyzes RuoYi 3.9.2's BaseEntity and TreeEntity base classes, showing how audit fields, a dynamic params Map, and tree-specific fields are consolidated to eliminate boilerplate across hundreds of entities, with concrete MyBatis mapper examples and design trade-off discussions.
This article walks through implementing a financial-grade double-entry bookkeeping system using Spring Boot 3, MyBatis, and MySQL, covering domain modeling with immutable entries and derived balances, a posting engine with idempotency and debit-credit validation, balance calculation via snapshots and incremental deltas, end-of-day trial balance verification, cross-system reconciliation, and production concerns like precision handling, sharding strategies, and hot-account mitigation.
This tutorial demonstrates how to configure MyBatis SQL statements using Java annotations instead of XML, covering Maven dependencies, project structure, core configuration files, entity mapping, dynamic SQL providers, mapper interfaces with @Select/@Insert/@Update/@Delete annotations, service layer implementation, and JUnit testing.
The article benchmarks multiple approaches for inserting 300,000 records into MySQL, showing that naive single inserts take over 4 hours, while optimized batched inserts using MyBatis or JDBC with proper batch sizes (1000–5000) and transaction management achieve 13–24 seconds, and summarizes key optimization strategies.
This tutorial demonstrates how to integrate Spring with MyBatis and JUnit using only annotations, covering Maven dependencies, Druid data source configuration, MyBatis SqlSessionFactory setup, mapper scanning, dynamic SQL with @SelectProvider, service layer wiring, and JUnit test execution with Spring's test context framework.
A comprehensive 14k-word technical deep-dive into MyBatis covering its semi-automatic ORM design, four core components (Executor, StatementHandler, ParameterHandler, ResultSetHandler), dynamic SQL parsing via SqlNode trees, two-level caching, plugin mechanism, Spring integration, and source-code-level analysis of 11 key classes with practical best practices and common pitfalls.
This tutorial demonstrates how to implement Spring declarative transaction management using only annotations, covering project setup, configuration classes, MyBatis integration, service layer @Transactional usage, and JUnit tests verifying commit and rollback behavior.
This tutorial walks through configuring MyBatis with XML for database operations, covering Maven dependencies, project structure, core configuration files, mapper interfaces, dynamic SQL, and JUnit testing with a complete employee CRUD example.
This article introduces an open-source code generator that automatically creates complete Spring Boot CRUD layers—entities, DAOs, MyBatis mappers, services, converters, and controllers—from database schemas or SQL, featuring customizable templates with dynamic parameters and reusable code blocks for team-specific conventions.
A senior Java engineer recounts how a team evolved from a MyBatis interceptor for environment-based data isolation to a clean annotation-plus-AOP solution after a junior developer's ThreadLocal-based quick fix caused nested-call bugs and scattered boilerplate across the codebase.
This article analyzes MyBatis sharding execution principles through ShardingSphere source code, explaining how logical tables map to physical tables, why three-table joins fail without sharding keys in WHERE clauses, and how to debug routing issues.
This article explores Java's three core metaprogramming mechanisms—reflection, dynamic proxy, and MethodHandle—with code examples, API references, performance comparisons, and real-world usage in frameworks like Spring AOP, MyBatis, and RPC systems.
This article dissects MyBatis startup internals, explaining how Mapper interfaces and XML SQL are parsed into MappedStatement objects, the role of SqlSource in static vs dynamic SQL, the #{}/${} difference, and how JDK dynamic proxies enable interface method execution without implementation classes.
This article demonstrates how to store four independent notification channel switches (SMS, email, in-app, WeChat) in a single MySQL TINYINT column using bitwise operations, covering schema design, SQL queries, Java enum and utility classes, service and controller layers, MyBatis mapper, extensibility to N channels, and key considerations like indexing, concurrency, and readability.
Manually creating entity classes, CRUD interfaces and SQL for dozens of tables can consume dozens of hours, so the author built an open‑source tool that automatically generates the full backend stack—from table definition to Java models, MyBatis mappers, services and controllers—dramatically accelerating development.
The article wraps up the "Design Pattern Dissection" series by showing how the 23 GoF patterns appear in JDK, Spring and MyBatis, clarifying the most confusing pattern pairs, warning against over‑design, and presenting a comprehensive map that links each pattern to the seven core design principles.
BeanSearcher, a read‑only Java ORM, generates SQL from declarative annotations and maps HTTP query parameters directly to query conditions, allowing complex multi‑table, aggregation and sorting queries with a single line of code and claiming performance up to a hundred times faster than MyBatis.
The article recounts a six‑year veteran’s encounter with a tangled Java data‑isolation implementation, explains how a custom MyBatis interceptor and annotation were used to inject and filter an env field across dozens of tables, and reflects on the code smell and refactoring lessons learned.
This article provides a comprehensive Spring container walkthrough covering the full lifecycle—from bean definition scanning and proxy creation during startup to request handling, AOP interception, transaction and caching mechanisms—plus detailed answers to 12 common interview questions with code examples and best‑practice recommendations.
This article examines common pitfalls and misconceptions in field‑level encryption, explains why AES‑GCM and proper AAD are essential, outlines threat modeling, key hierarchy, blind indexing for searchable data, migration strategies, key rotation, performance considerations, and secure integration with MyBatis, Kubernetes, and Vault.
The article explains MyBatis’s three‑stage process—building an in‑memory mapping dictionary at startup, using JDK dynamic proxies to bind interface methods to that dictionary, and the runtime execution flow that translates a mapper call into JDBC operations, highlighting design choices such as builder chains, pre‑loading, and composition over inheritance.
The article compares several ways of inserting 300,000 MySQL rows—single‑row loops, an un‑batched MyBatis attempt that hits the max_allowed_packet limit, and a tuned batch strategy that commits every 1,000 rows—showing how the optimized batch reduces the runtime from hours to just 13 seconds and summarizing best‑practice tips.
This article demonstrates four techniques for persisting flexible JSON data in Spring Boot 3.5.0—using JPA @Convert with AttributeConverter, Hibernate @JdbcTypeCode, a custom MyBatis TypeHandler, and MyBatis‑Plus annotations—complete with code snippets, test cases, and execution results.
This guide walks through a full MyBatis unit‑testing suite built on Spring Boot 3.x and JDK 17+, showing how to configure Maven dependencies, set up an H2 datasource, write POJOs, define mapper interfaces and XML, and verify features such as mapper proxies, parameter binding, dynamic SQL, resultMap mapping, camel‑case conversion and first‑level caching with JUnit 5.
This article walks through three common data‑masking approaches—SQL queries using string functions, a Java‑based "sensitive‑plus" plugin, and the mybatis‑mate‑sensitive‑jackson extension—showing configuration, code examples, and how each method masks phone numbers, ID cards and other personal fields.
The article explains how layered caching in Java back‑ends—combining MyBatis first‑ and second‑level caches with a service‑layer Caffeine + Redis cache—affects cache granularity, consistency, distribution, and performance, and provides concrete configuration examples, code snippets, and best‑practice guidelines.
This article analyzes MybatisPlus Pro, explaining how it eliminates repetitive CRUD code in MyBatis‑Plus projects by providing a BaseController and utility classes that auto‑generate service and controller layers, while also detailing its internal mechanisms, advantages, drawbacks, suitable scenarios, and common pitfalls.
In a high‑concurrency transaction system, the author diagnosed a 30‑second API latency caused by costly SQL scans and Java Map creation on over two million rows, then applied SQL aggregation, moved counting logic into PostgreSQL, and introduced a Caffeine cache, ultimately reducing the response time to under 0.8 seconds while highlighting relational‑database limits for massive data.
Faced with massive MyBatis log files that made manual slow‑SQL hunting impossible, the author designed a SpringBoot‑Vue‑MySQL system that parses logs with multithreaded batch processing, flexible regex templates, real‑time performance monitoring, and virtual‑scroll UI, achieving 55 000 lines/s throughput and over 95% matching accuracy.
An ORM parameter type mismatch caused MySQL to perform implicit conversion on a VARCHAR index column, turning an indexed query into a full table scan that saturated connection pools, thread pools, Kafka consumers, and upstream services during a high‑traffic promotion, illustrating the full‑stack impact and remediation steps.
The article walks through a real production incident caused by a massive IN‑list query, then presents a complete methodology for designing, implementing, and tuning an enterprise‑grade MyBatis persistence layer—including core execution chain, caching strategies, batch processing, read/write splitting, sharding, observability, and deployment best practices.
MyBatis generates mapper implementations at runtime using JDK dynamic proxies; the proxy intercepts interface calls, builds a statementId from the interface’s fully‑qualified name and method name, looks up the corresponding MappedStatement via the namespace‑id convention, and delegates execution to SqlSession, eliminating the need for a concrete class.
A newcomer swapped MyBatis for MyBatis‑Plus in an old Java project, which caused a runtime exception about unsupported java.time.LocalDateTime conversion; the root cause was a MyBatis version change and an outdated MySQL JDBC driver, fixed by upgrading the driver.
This article explains why naïve per‑record inserts or updates in SpringBoot cause severe performance problems, analyzes three common mistakes, and demonstrates how MyBatis batch processing—through connection reuse, prepared‑statement reuse, and batch transaction commits—can speed up operations by tens of times, with practical code examples and configuration tips for handling millions of rows.
When a single database table grows to millions of rows, query performance and storage become bottlenecks, and this article explains why sharding is needed, introduces Sharding-JDBC as a lightweight solution, and walks through the complete setup, configuration, code implementation, testing, and advanced concepts such as sharding strategies, key generation, binding tables, and broadcast tables for SpringBoot projects.
This article introduces the MyBatisCodeHelper-Pro IntelliJ IDEA plugin, outlines its popular features such as mapper navigation, @Param generation, XML creation, pagination support, Spring integration, and SQL log conversion, and provides step‑by‑step installation and usage instructions with screenshots.
This guide explains how to configure multiple data sources in SpringBoot to achieve basic read‑write separation, covering applicable scenarios, step‑by‑step setup of master and slave DataSources, SqlSessionFactory and SqlSessionTemplate beans, package‑based routing, transaction considerations, common pitfalls, and best‑practice recommendations.
This article walks through a full SpringBoot‑MyBatis integration, covering Maven dependencies, application.yml configuration, database schema, entity definition, mapper XML, service layer with transactions and pagination, REST controller endpoints, key features, and common pitfalls.
The article analyzes MyBatis’s 20,000‑line source code, showing how it applies more than ten classic design patterns—such as Factory, Singleton, Builder, Adapter, Proxy, Composite, Decorator, Template, Strategy, and Iterator—to decouple complex ORM scenarios, improve extensibility, and illustrate practical implementation details.
A newcomer replaced MyBatis with MyBatis‑Plus in an old MySQL‑based project, triggering a "Conversion not supported for type java.time.LocalDateTime" error, which was traced to MyBatis 3.5.1 dropping built‑in type handling and an outdated mysql‑connector‑java, and resolved by upgrading the connector and adjusting validation logic.
The article explains why a Spring Boot project using MyBatis may throw the ‘Property sqlSessionFactory or sqlSessionTemplate are required’ error and provides two concrete fixes: downgrade the spring-boot-starter-parent version and switch the MySQL driver from 8.x to 5.7.
MyBatis, a widely used Java persistence framework, blends SQL mapping with traditional JDBC, requiring developers to write SQL manually, offering greater flexibility and performance than full ORM solutions like Hibernate, while providing only persistence operations without encapsulating complex business logic.
A newcomer replaced MyBatis with MyBatis‑Plus in an old MySQL‑based project, encountered a "Conversion not supported for type java.time.LocalDateTime" error, traced it to MyBatis 3.5.1 dropping built‑in type handling and an outdated mysql‑connector‑java driver, and resolved it by upgrading the driver while also fixing a related validation bug that caused production failures.
This article explores the challenges of sudden traffic spikes that overload applications and databases, and presents a step‑by‑step design, implementation, and optimization of a MyBatis plugin that intercepts SQL, applies fingerprint‑based rate limiting, and integrates with Joycode for rapid development and testing.
This article explains the challenges of sudden traffic bursts on applications and databases, outlines a MyBatis plugin design that intercepts SQL, uses fingerprint‑based throttling with configurable policies, and details the development, optimization, testing, and documentation steps performed with pair‑programming assistance.
This article explains how Lombok’s generation of getter/setter methods for fields whose second character is uppercase can cause MyBatis to map properties incorrectly, leading to null values, and also examines why the @Accessor(chain=true) annotation breaks EasyExcel’s reflection, offering concrete solutions for each case.
This article explains the concepts, characteristics, default states, and usage patterns of MyBatis first‑level (SqlSession) and second‑level (Mapper) caches, provides Java code demos for each, and compares their scope, lifecycle, consistency, and suitable scenarios.
This article explains the MyBatis plugin mechanism, walks through implementing the Interceptor interface, configuring the plugin in mybatis-config.xml, provides a complete code example, and outlines common use cases such as SQL logging, performance monitoring, permission control, and automatic field filling.
This article explains how to replace manual encryption code with a lightweight, annotation‑driven solution that uses a custom MyBatis interceptor to automatically encrypt and decrypt sensitive fields such as phone numbers, emails, and ID cards, improving code readability, maintainability, and security compliance.
The article analyzes the cumbersome MyBatis IN‑statement foreach template, explores three implementation paths, and presents a custom LanguageDriver that lets developers write simple "in #{param}" syntax, cutting XML boilerplate in half while generating correct SQL at runtime.
This article explains MyBatis’s plugin mechanism, detailing the Interceptor interface methods, how plugins form an interceptor chain to wrap core components like Executor, and provides a step‑by‑step example of a logging plugin with code and configuration, illustrating the runtime flow and extension capabilities.
This article explains the interview focus on MyBatis placeholders, detailing the syntax, security implications, performance differences, appropriate scenarios, best‑practice guidelines, common pitfalls, and provides concrete code examples to help candidates master #{} and ${} usage.
A production incident where payment requests succeeded but no order rows were inserted was traced to a missing commit in a special code path, causing a polluted connection to be reused by other services; the article details the debugging steps, root‑cause analysis, code fixes, and preventive measures.
A production incident where payment orders appeared successful but were not persisted was traced to a missing commit in a special‑case branch, causing a polluted connection to be reused by Spring's transaction manager, leading to intermittent failures that were resolved by fixing the commit logic and adding connection‑pool health checks.
This article walks through a real‑world data‑migration case where 100,000 rows were moved from an old system to a new one, showing how naive per‑row inserts took five minutes and how a series of optimizations—batch SQL, JDBC batch mode, and multithreaded parallelism—reduced the runtime to just three seconds, while also covering common pitfalls and the final high‑performance implementation.
The article examines a production OutOfMemoryError caused by MyBatis SQL construction, explains heap and metaspace exhaustion, analyzes MyBatis source code, reproduces the issue with JVM settings, and offers practical recommendations to prevent similar memory failures.
The article walks through three concrete optimizations—batch SQL, JDBC batch mode with rewriteBatchedStatements, and multithreaded parallel inserts—that shrink a 100,000‑row MyBatis insertion from five minutes to three seconds, while highlighting configuration details, performance gains, and common pitfalls.
The article walks through turning a naïve MyBatis loop that took five minutes to insert 100,000 rows into a high‑performance solution that finishes in three seconds by applying batch SQL, JDBC batch mode with rewriteBatchedStatements, and multithreaded parallel execution, while highlighting pitfalls and best‑practice configurations.
The article details a step‑by‑step migration from MyBatis 3.5.0 to MyBatis‑Plus 3.1.1, explains why the conversion error for java.time.LocalDateTime appears after the switch, shows how to trace the root cause through stack traces, upgrades the mysql‑connector‑java to 5.1.37 (and later 5.1.42) to resolve the issue, and shares broader lessons about component upgrades and unexpected bugs.
The article recounts a developer’s painful experience with PageHelper, detailing how duplicate registrations, truncated result sets, and password‑update errors stem from the plugin’s ThreadLocal pagination handling, and explains the underlying code paths and safe usage practices.
The article examines how MyBatis’s massive source code employs more than ten classic design patterns—creational, structural, and behavioral—to decouple complex scenarios, illustrating each pattern with diagrams, typical use‑cases, and related classes within the framework.
A legacy project using MySQL 5.7, MyBatis 3.5.0 and mysql‑connector‑java 5.1.26 encounters a "Conversion not supported for type java.time.LocalDateTime" error after switching to MyBatis‑Plus 3.1.1, which is traced to MyBatis 3.5.1 dropping built‑in LocalDateTime handling and the old connector not supporting the type, requiring an upgrade to mysql‑connector‑java 5.1.37 or later.
This article explains how Lombok’s unconventional getter/setter method names cause MyBatis to store enum fields as null, why the @Accessor(chain=true) annotation breaks EasyExcel exports, and provides concrete code‑level solutions to resolve both issues in Java backend projects.
The article examines unexpected bugs caused by PageHelper’s hidden LIMIT clause injection in MyBatis projects, explains how ThreadLocal pagination parameters persist across requests, and provides practical guidelines and code examples to avoid and clean up these issues.
This guide explains the concept of multi‑DataSource coexistence, when it is appropriate, step‑by‑step configuration for MySQL and TDengine, transaction manager handling, custom annotations, mapper scanning, differences from dynamic routing, common pitfalls, and best‑practice usage in a Spring‑MyBatis backend.
This article compares five MyBatis pagination techniques—including raw LIMIT SQL, RowBounds, custom window‑function queries, interceptor‑based pagination, and the PageHelper plugin—explaining their principles, code examples, performance trade‑offs, and ideal usage scenarios.
This guide shows how to achieve multi‑tenant data isolation in a Spring Boot application by creating a MyBatis interceptor that modifies SQL statements using JSqlParser, covering dependency setup, interceptor implementation, testing, and the rationale for intercepting the StatementHandler.prepare method.
This guide explains how to configure Spring Boot applications to use multiple coexisting DataSource beans—such as MySQL and TDengine—without runtime switching, covering bean definitions, MyBatis mapper scanning, transaction manager setup, custom @Transactional annotations, and common pitfalls, enabling clean separation of business, log, and time‑series data.
This article explains how to eliminate repetitive manual encryption code in Java applications by using a custom @Encrypted annotation together with a MyBatis interceptor, enabling transparent AES‑GCM encryption and decryption of sensitive fields such as phone numbers, emails, and ID numbers.
This article explains a Spring Boot and MyBatis solution that automatically encrypts and decrypts sensitive database fields via an @Encrypted annotation, eliminating manual cryptographic code, reducing maintenance overhead, and preserving performance while ensuring strong data protection.
This article explains how Lombok generates getter and setter method names for fields with a lowercase first letter and uppercase second letter, causing mismatches with MyBatis property parsing and EasyExcel’s cglib reflection, and provides practical solutions.
SQL injection lets attackers turn simple input fields into destructive commands that can delete or compromise databases; the article explains how string‑concatenated queries become vulnerable, demonstrates the attack step‑by‑step, and shows how parameterized queries via PreparedStatement and MyBatis’ #{ } syntax, plus defense‑in‑depth measures, effectively mitigate the risk.
The article examines how MyBatis leverages around ten classic design patterns—grouped into Creational, Structural, and Behavioral categories—to decouple complex ORM logic, describing each pattern’s role, typical usage scenarios, and related components within the framework.
The article dissects MyBatis' mechanisms for preventing SQL injection, compares the safe #{ } syntax with the risky ${ } syntax, explains the underlying PreparedStatement workflow, and provides concrete best‑practice guidelines and code examples for secure usage.
The article walks through replacing MyBatis 3.5.0 with MyBatis‑Plus 3.1.1 in a legacy Java project, uncovers version‑specific LocalDateTime conversion failures, shows how upgrading mysql‑connector‑java resolves them, and reflects on the broader impact of component upgrades on production stability.
The article explains why MyBatis can execute database queries without concrete method implementations by using JDK dynamic proxies, detailing the roles of MapperProxy, MapperMethod, SqlSession and Executor, and walks through the four‑step process from proxy creation to result mapping.
This article walks through nine powerful MyBatis dynamic SQL tags—including foreach, if, choose, selectKey, trim, and sql fragments—explaining their attributes, common pitfalls, and providing complete XML and Java examples to help developers write cleaner, error‑free queries and updates.
This article explains why @Transactional fails in multithreaded MySQL insert scenarios, demonstrates how to split large data sets, configure a thread pool, and use SqlSession with manual commit to guarantee atomicity across parallel threads, complete with runnable code examples and test results.
This article explains how to handle large‑scale data insertion with multithreading in Spring, why @Transactional fails in child threads, and demonstrates two approaches—manual SqlSession control and thread‑pool execution—to guarantee atomic rollback across all threads.
The article analyzes a Lombok @Data‑generated getter/setter naming mismatch that causes MyBatis to store a null enum field, walks through debugging, examines MyBatis’s PropertyNamer source, demonstrates the issue with test code, and then explains a similar @Accessor(chain=true) problem in EasyExcel, offering concrete workarounds for both.
The article explains how Flowable, a fork of Activiti, achieves high extensibility and performance through a four‑layer modular architecture, MyBatis‑based persistence, core engine services, dual Java/REST APIs, pluggable extensions, a detailed state machine, async execution, transaction safety, and practical tuning tips.
This article analyzes a MyBatis batch‑insert failure caused by the useGeneratedKeys setting after upgrading from 3.4.6 to 3.5.6, explains the root‑cause in the Jdbc3KeyGenerator, and provides both temporary and permanent solutions with code examples.
This article compares MyBatis and Spring Data JPA, explaining their core concepts, performance, flexibility, learning curve, community support, and real‑world scenarios, and provides code examples and decision criteria to help developers choose the right data‑access framework for their Spring Boot applications.
This article describes the design and implementation of a high‑performance log‑analysis system for massive MyBatis logs, covering problem analysis, technology selection, architecture, multithreaded parsing, flexible regex templates, performance monitoring, pitfalls, optimization practices, results, and future plans.
This article explains how oversized database query results can cause JVM memory spikes and OOM errors, and shows how to use MyBatis interceptors to monitor, limit, and protect memory consumption with non‑intrusive code, Prometheus metrics, and configurable thresholds, ultimately improving system stability and performance.
This article explains why storing plain‑text sensitive fields such as phone numbers is unsafe, then demonstrates how to use a custom MyBatis TypeHandler to automatically encrypt data on insert and decrypt it on query, complete with code samples, configuration steps, and test results.
This guide explains MyBatis's two‑level caching mechanism, shows how to use the default first‑level cache and manually enable the second‑level cache in a Spring Boot project, includes code examples, test cases, third‑party Ehcache integration, and key considerations for safe deployment.
This article explains how Lombok’s automatic getter/setter generation can cause MyBatis to store enum fields as null, details the underlying JavaBeans naming conflict, and also reveals why EasyExcel fails with @Accessor(chain=true) annotations, offering practical solutions for both problems.
This article explains how to protect sensitive user information such as phone numbers in a MySQL database by using MyBatis TypeHandler to automatically encrypt data on insert and decrypt it on query, complete with code examples and configuration steps.
This article explains why @Transactional fails in multi‑threaded Spring services, provides a utility for splitting large data sets, shows thread‑pool configuration, demonstrates a failing transaction scenario, and presents a solution using manual MyBatis sqlSession commit to guarantee atomic rollback across all threads.
This guide walks through two approaches for configuring multiple databases in a Spring Boot and MyBatis project—native multi‑data‑source beans and the dynamic‑datasource‑spring‑boot‑starter—covering project structure, Maven dependencies, Java configuration, mapper setup, usage examples, common pitfalls, and a concise summary of when to choose each method.
The article introduces a self‑built utility that automatically generates Java backend code—including entity classes, DAO interfaces, service implementations, and controllers—based on database table definitions, dramatically reducing the manual effort of creating dozens of tables and their associated CRUD logic.
This guide lists the 15 most common MyBatis pitfalls—from SQL injection and mismatched field mappings to N+1 queries and improper pagination—paired with concrete best‑practice solutions, code snippets, and configuration tips to make your persistence layer safer, more efficient, and easier to maintain.
This article demonstrates how to insert 300,000 rows into a MySQL table using MyBatis and JDBC, compares naïve single‑batch and per‑row approaches, presents optimized batch‑processing code with configurable batch sizes and wait times, and shares practical performance‑tuning tips such as index handling and connection‑pool configuration.
This article compares five major Java database access technologies—JDBC, Hibernate, Spring Data JPA, JOOQ, and MyBatis—detailing their code examples, strengths, weaknesses, and ideal use cases, while also offering a downloadable Spring Boot 3 case collection PDF for hands‑on practice.
The article reviews Java technologies that have become outdated—such as JSP, Struts, Hibernate, Applet, Swing, JDBC, and XML—explaining why they no longer merit learning and recommending modern alternatives like Spring MVC, MyBatis, and a deep understanding of Servlets for today's backend development.
This article explains MyBatis streaming queries, introduces the Cursor interface and its methods, demonstrates common pitfalls, and provides three practical solutions—using SqlSessionFactory, TransactionTemplate, or @Transactional—to keep database connections open while processing large result sets efficiently.
This article explains MyBatis streaming queries using the Cursor interface, demonstrates common pitfalls such as closed connections, and provides three practical solutions—including SqlSessionFactory, TransactionTemplate, and @Transactional—to reliably process large result sets with minimal memory usage.