This article compiles over a thousand interview questions and detailed explanations covering core Java fundamentals, multithreading, Spring framework, Redis, MyBatis, and related backend technologies, offering a free downloadable resource to help candidates prepare effectively for major tech company interviews.
This tutorial explains how to integrate MyBatis into a Spring Boot project, covering setup, basic CRUD examples, dynamic SQL techniques, one‑to‑one and one‑to‑many mappings, pagination support, and provides complete code snippets for each step.
This article explains how a high‑traffic e‑commerce system reduced database QPS by over 80% and response latency by more than 40% through a systematic DAO‑level caching solution, detailing the background, design trade‑offs, implementation steps, global cache architecture, deployment practices, and observed limitations.
This article thoroughly explains how MyBatis binds mapper interfaces to XML files, details the step‑by‑step SQL execution flow—including mapper retrieval, statement preparation, parameter handling, and result mapping—and demonstrates how to create custom typeHandlers for both input parameters and result sets.
This article dissects MyBatis’s internal workflow, explaining how mapper interfaces are linked to XML files, detailing the step‑by‑step SQL execution process, and demonstrating how to create and apply custom typeHandlers for parameter setting and result mapping, all based on MyBatis 3.5.5 source code.
This article explains MyBatis's first-level (SqlSession-scoped) and second-level (Mapper-scoped) caching mechanisms, their default behaviors, key generation, configuration options, and the impact of Spring integration, and provides recommendations for disabling caches in distributed environments to avoid data inconsistency.
This article explains MyBatis caching fundamentals, detailing first- and second-level cache concepts, configuration, cache invalidation scenarios, and custom cache integration with EHCache, supplemented by practical code snippets and quiz questions to illustrate cache behavior across SqlSessions.
This guide walks you through installing the MyBatisCodeHelper‑Pro IntelliJ plugin, configuring it to generate Java entity, DAO, mapper and service code, customizing type mappings, creating SQL scripts, and using shortcuts to produce find, update, delete, and pagination methods efficiently for backend development.
Drawing on two decades of Java experience, this article evaluates outdated Java technologies—JSP, Struts, Hibernate, and others—based on real‑world development relevance, interview usefulness, and depth of understanding, and offers clear recommendations on what to skip and what to master.
This guide walks you through integrating MyBatis with Spring Boot, covering basic CRUD operations, dynamic SQL constructs like if, choose, where, set, foreach, as well as advanced mapping techniques, pagination plugins, and practical code examples to help you master MyBatis in real-world projects.
This article presents a detailed performance test of inserting massive data into MySQL with Java, comparing three strategies—MyBatis lightweight insertion without transactions, direct JDBC handling with and without transactions, and JDBC batch processing—showing timing results for millions of rows and offering practical recommendations for high‑throughput data loading.
This article explains the core concepts of MyBatis caching, details how first‑level and second‑level caches work, shows configuration options, illustrates cache invalidation scenarios, and demonstrates custom cache integration with EHCache through practical code examples and test questions.
This article walks through the most common MyBatis SQL injection patterns—like, IN, and ORDER BY—explains why they occur, and provides a step‑by‑step hands‑on methodology for locating, reproducing, and confirming the flaws in a real Java CMS project.
This article provides a comprehensive tutorial on using Spring annotations for pure annotation‑based development, defining beans, managing bean scopes, performing various injection techniques, reading configuration properties, and integrating Spring with MyBatis, complete with code examples and best‑practice tips.
This article demonstrates how to securely store and retrieve sensitive fields such as phone numbers in a MySQL database by creating a custom Java Encrypt class, a MyBatis TypeHandler for automatic encryption/decryption, configuring the mapper XML, and verifying the solution with test results.
This article walks through MyBatis's complete query lifecycle—from configuration parsing, SqlSessionFactory creation, and mapper loading to the actual SELECT execution—while reproducing a pre‑3.4.5 bug caused by foreach variable leakage and presenting the official fix and upgrade recommendations.
This article presents a comprehensive Java web application that combines movies, music, and books, built with Spring Boot, MyBatis, Redis, and Nginx, and provides detailed environment specifications, architecture diagrams, feature screenshots, and step‑by‑step deployment instructions.
This article provides a step‑by‑step tutorial on using Spring annotations for bean definition, component scanning, scope management, autowiring, qualifier usage, simple value injection, property file loading, and finally demonstrates how to integrate Spring with MyBatis for streamlined data access in Java backend projects.
This guide walks through common MyBatis SQL injection patterns—like fuzzy queries, IN clauses, and ORDER BY misuse—showing how to locate vulnerable XML, trace the call chain, and confirm exploitation with a crafted request, providing practical steps for Java security auditors.
This article compiles a large set of interview questions frequently asked by top tech companies, covering Java fundamentals, multithreading, Spring framework, MyBatis, Redis, and related concepts, and provides a free QR‑code link for downloading the complete question set with answers.
This article explains the principles, implementation steps, and configuration of MyBatis first‑level (SqlSession) and second‑level (mapper) caches, compares their scopes and behaviors, and provides practical guidance on when and how to enable each cache to improve database query performance.
This article demonstrates how to mask sensitive data such as phone numbers and ID cards using SQL functions, introduces Java masking libraries, and provides a complete MyBatis-Mate Sensitive Jackson example with configuration, custom strategies, entity annotations, controller endpoints, and sample responses.
The article advises that POJO class attributes should always use wrapper types without preset default values, illustrating several pitfalls such as null‑overridden defaults during Jackson deserialization, BeanUtils copy failures, MyBatis dynamic SQL issues, and RPC/API default‑value bugs.
This article compares Fluent MyBatis, native MyBatis, and MyBatis Plus by implementing a student score aggregation query, showcasing code examples, generator settings, and a detailed feature matrix to help developers choose the most efficient ORM for complex SQL construction.
After taking over a system via a server image, the author uncovered malicious modifications that used a ternary expression to force id=1, causing MyBatis to generate a “where 1=1” clause that deleted the entire T_QUART_DATA table, and later discovered cron jobs that removed core jars, illustrating a thorough forensic debugging process.
This article explains how to model a session that contains multiple scenes in a Java backend, defines corresponding entity classes, creates a MyBatis custom mapper with XML result mapping, and implements service and Spring MVC controller layers to expose the data via a clean API.
This comprehensive guide explains MyBatis fundamentals, compares it with Hibernate, details its lifecycle, configuration, dynamic SQL, caching, lazy loading, batch operations, pagination, and plugin development, providing code examples and best‑practice recommendations for Java backend developers.
An in‑depth guide explains why using MyBatis’s foreach for bulk inserts can cause severe performance degradation, especially with large tables, and demonstrates how switching to ExecutorType.BATCH or limiting batch sizes to 20‑50 rows dramatically reduces insertion time from minutes to seconds.
The article explains why MyBatis batch inserts using a foreach-generated single INSERT statement can cause severe CPU and latency issues, and demonstrates how to achieve fast bulk insertion by limiting batch size or switching to ExecutorType.BATCH with code examples.
The article explains why MyBatis foreach‑based batch inserts can cause extreme CPU usage and long execution times, demonstrates how combining multiple VALUES into a single INSERT or using ExecutorType.BATCH dramatically improves performance, and provides practical code examples and sizing recommendations.
This article explains common anomalies caused by PageHelper in MyBatis projects, such as duplicate registrations and unexpected LIMIT clauses, analyzes the underlying ThreadLocal mechanism, and provides practical guidance on correctly using startPage() and clearPage() to prevent pagination bugs.
This article explains the origins and purpose of Spring transactions, demonstrates how to quickly set them up with code examples, explores key features and common pitfalls, and provides an in‑depth comparison of the REQUIRED, REQUIRES_NEW, and NESTED propagation types for robust backend development.
This article examines unexpected bugs caused by PageHelper in a Java/MyBatis project—such as duplicate registrations, limited dropdown results, and password‑reset errors—traces them to ThreadLocal misuse, explains the library’s internal pagination flow, and offers practical fixes to avoid these pitfalls.
This article explains how to use MyBatis plugins to transparently encrypt specified database fields on write and decrypt them on read, covering the requirement background, system architecture, interceptor design, annotation usage, mapper adjustments, handling of pagination count queries, and practical implementation details.
The article demonstrates how to implement lightweight field-level encryption in MyBatis by adding encrypted columns, creating a custom interceptor that encrypts annotated parameters on write and decrypts them on read, handling executor, statement, parameter, and result set processing, and addressing pagination count queries.
This article explains how PageHelper integrates with MyBatis, analyzes common pagination bugs such as unexpected LIMIT clauses, duplicate registrations, and password‑reset errors, and demonstrates the internal ThreadLocal handling, startPage usage, and proper cleanup to avoid thread‑local pollution.
This article explains the fundamentals of SQL injection attacks, outlines their severe consequences, and provides a comprehensive set of prevention principles and practical measures—including parameterized queries, strong typing, input validation, and secure MyBatis configurations—to help developers safeguard backend applications and databases.
This article demonstrates how to mask sensitive data such as phone numbers, ID cards, and emails in MySQL and Java applications by combining SQL string functions with the MyBatis‑Mate Sensitive Jackson plugin, providing complete configuration, custom strategies, and runnable Spring Boot examples.
This article provides a comprehensive analysis of MyBatis, covering its core architecture, the process of obtaining SqlSessionFactory and SqlSession, the dynamic proxy mechanism for mappers, the execution flow of SQL statements, the plugin system, first‑ and second‑level caching strategies, and how Spring manages MyBatis mappers through factory beans and import registrars.
This guide walks through setting up a front‑back separated student management system, detailing Vue‑based front‑end deployment, SpringBoot + MyBatis back‑end configuration, database initialization, core features for admin, teacher, and student roles, and provides code snippets and screenshots to illustrate the complete workflow.
The guide recommends fine‑grained MySQL management in a MyBatis‑based order system—avoiding generic or dynamic SQL, explicitly using indexes, listing columns, limiting results, batching inserts, and checking row counts—while applying appropriate concurrency control (pessimistic FOR UPDATE or optimistic versioning) to improve performance, stability, and data integrity.
This guide explains what caching is, why it’s essential for database‑driven applications, and how MyBatis implements first‑level and second‑level caches, including configuration steps, sample code, execution results, and key considerations to ensure effective cache usage.
This guide explains how to create a music website using Vue 3 for the front‑end and Spring Boot with MyBatis for the back‑end, covering project features, technology stack, development environment, repository cloning, resource setup, configuration, and launch commands.
When using MessageFormat to inject integer parameters into dynamically generated MyBatis SQL, large numbers are automatically formatted with commas (e.g., 10000 becomes 10,000), which can break SQL statements, and the article explains why this happens and how to prevent it by converting numbers to strings before formatting.
This article introduces MyBatis‑Mate, an official MyBatis‑Plus extension that provides enterprise‑grade capabilities such as dictionary binding, field encryption, data masking, dynamic table maintenance, audit logging, sharding, multi‑datasource switching, and customizable data‑scope handling, all illustrated with code examples.
This comprehensive guide explains what MyBatis is, compares it with Hibernate, details its core components, configuration, dynamic SQL, caching, plugins, pagination, and practical usage patterns, providing Java developers with clear examples, code snippets, and visual diagrams to master the framework efficiently.
This article explains how to use MyBatis dynamic SQL tags—including if, where, set, choose, foreach, sql fragments, and bind—to build flexible queries and updates, with detailed code examples and tips for handling null parameters and avoiding syntax errors.
This article examines a MyBatis bug present in versions prior to 3.4.5 by reproducing the issue, walking through the complete query execution flow from configuration parsing to result handling, identifying the root cause in foreach variable binding, and presenting official fixes and practical work‑arounds.
This guide demonstrates how to construct flexible MyBatis dynamic SQL statements using tags such as if, where, set, choose, foreach, sql fragments, and bind, showing practical examples for conditional queries, updates, and reusable SQL components to streamline backend data access.
This article presents a comprehensive performance testing case study of a multi‑table database query interface, detailing common performance metrics, response‑time classifications, step‑by‑step load‑test results, root‑cause analysis of CPU, memory, and connection‑pool bottlenecks, and demonstrates how tuning Druid’s maxActive and maxWait parameters optimizes throughput and reduces latency.
This article introduces MyBatis-Mate, an official MyBatis-Plus extension that offers enterprise‑grade capabilities such as dictionary binding, field encryption, data masking, dynamic DDL generation, multi‑datasource sharding, data‑scope filtering, and SQL performance logging, complete with Maven dependency setup and code examples.
This article demonstrates practical techniques for data masking, covering MySQL string functions for phone and ID masking, a Java library for various sensitive fields, and a MyBatis‑Mate extension that applies custom and built‑in masking strategies through annotations and REST endpoints.
This article demonstrates how to mask sensitive phone numbers and ID cards directly in MySQL, introduces a Java masking library, and provides a complete MyBatis‑Mate extension with custom strategies, configuration files, and sample Spring Boot code to protect personal data in applications.
This tutorial explains how to configure Spring Boot with a single DataSource, integrate MyBatis, and extend the setup to a dynamic multi‑DataSource using AbstractRoutingDataSource, custom annotations, and AOP, covering connection pool setup, property mapping, and transaction management.
This article explains three MySQL pagination techniques in Java—using LIMIT clauses, MyBatis RowBounds, and the MyBatis‑PageHelper plugin—providing syntax, XML and Java code examples, execution results, and practical recommendations for efficient data retrieval in backend development.
This article explains how to create a custom MyBatis Interceptor using Java dynamic proxies, detailing the Interceptor interface, the plugin generation process, the wrap and invoke methods, and common use‑cases such as pagination, SQL analysis, encryption, and performance monitoring.
The article walks through building a lightweight Java ORM framework from scratch, showing JDBC drawbacks, defining XML configuration and mapper files, implementing core components like SqlSessionFactory, SimpleExecutor, and reflection‑based parameter and result mapping, and demonstrating a working test that returns POJOs.
This article explains how to integrate Spring Boot with MyBatis, configure a single Druid data source, implement multi‑data‑source support using Spring's AbstractRoutingDataSource, create a dynamic data source with ThreadLocal, and wire everything together with custom annotations, aspects, and transaction management for backend Java applications.
This article walks through the challenges of inserting massive data sets with MyBatis, explains the inner workings of batch execution, highlights common mistakes with commit, clearCache and flushStatements, and presents progressively refined code examples—including Oracle-specific optimizations—to dramatically improve performance.
This article demonstrates how to accelerate massive MySQL data updates in a Spring Boot application by replacing naïve loops with manual transaction control, multithreaded processing, CountDownLatch synchronization, and UNION‑based SQL batching, achieving up to a five‑fold speed increase.
An in‑depth guide shows how to accelerate updating tens of thousands of MySQL rows in a Spring Boot‑MyBatis project by switching from automatic per‑record commits to manual transactions, applying multithreaded execution with CountDownLatch coordination, and using UNION‑based batch updates when native batch support is unavailable.
This article details Meituan's internal Sonic IDEA plugin, explaining hot‑deployment concepts, why they matter, the technical challenges, and Sonic's architecture—including agents, instrumentation, class reloading, Spring Bean/XML/MyBatis reloads, and real‑world deployment experience—showing how code changes can become effective in seconds instead of minutes.
This article explains how to implement the Singleton pattern in Java using both an enum‑based approach and a static inner‑class technique, providing thread‑safe examples from Spring Data JDBC and MyBatis along with Maven dependency snippets and detailed code illustrations.
This article walks readers through MyBatis batch processing from basics to advanced, highlighting common mistakes, explaining the roles of commit, clearCache, and flushStatements, and presenting three progressively refined code versions plus Oracle-specific optimizations to dramatically improve bulk insert performance.
This article explains MyBatis first‑ and second‑level caching, demonstrates how join queries can cause stale data when only the updated mapper's cache is cleared, and introduces a custom @CacheRelations annotation with a RelativeCache implementation that propagates invalidation across related mappers.
This article demonstrates how to efficiently update up to 50,000 MySQL records in a Spring Boot‑MyBatis application by comparing simple loops, manual transaction control, multithreaded execution with CountDownLatch coordination, and union‑based batch updates, while analyzing performance and connection‑pool considerations.
This article explains the principles and practical usage of MyBatis first‑level and second‑level caches, describing how caching reduces database load, showing configuration steps, code demonstrations, flow diagrams, and important considerations such as cache invalidation and LRU eviction.
This article introduces FastMybatis, a lightweight Java MyBatis extension that enables zero‑configuration CRUD operations across multiple databases, shows how to quickly set up a Spring Boot project with the starter, provides full code examples for entities, mappers, services, a comprehensive mapper method list, and demonstrates Query object usage for flexible data retrieval.
This article demonstrates how to dramatically speed up updating tens of thousands of records in a Spring‑MyBatis application by switching from automatic per‑operation commits to manual transaction control, applying multithreaded processing, tuning the Hikari connection pool, and using SQL UNION‑based batch updates.
This article explains the concepts of MyBatis first-level and second-level caches, demonstrates how they work with practical Java code, shows configuration methods, and highlights important considerations such as cache invalidation and eviction policies.
This article explains two techniques for creating an org.apache.ibatis.jdbc.SQL object in MyBatis—using an anonymous inner class with an initializer block and using method‑chaining builder style—provides code examples, explains the underlying Java syntax, and summarizes their differences.
This article explains the concept of streaming queries, introduces MyBatis's Cursor interface with its key methods, and provides three practical solutions—using SqlSessionFactory, TransactionTemplate, or @Transactional—to keep database connections open and avoid cursor‑closed errors in Spring MVC applications.
After encountering repeated errors and timeouts while retrieving the newly introduced 'nucleic acid code' in China, the author uses the experience to discuss why Spring Data JPA can cause performance problems in high‑concurrency systems compared to MyBatis, urging careful framework selection and deep SQL knowledge.
This article explains how to perform MySQL pagination manually in a Java backend using MyBatis by calculating offset and limit, adding total‑count queries, and exposing a REST endpoint that returns paged data and total records without relying on the PageHelper plugin.
This tutorial demonstrates how to add Create, Read, Update, and Delete functionality to a SpringBoot application using MyBatis XML mappers, configure the datasource in application.yml, and expose REST endpoints through a service and controller layer.
This beginner-friendly tutorial walks through creating a Spring Boot project, adding MySQL and MyBatis dependencies, configuring the application.yml file, and implementing UserMapper, User, and UserController classes to demonstrate a complete MySQL query demo.
This article walks through optimizing a slow MySQL batch import by first inserting a list directly, then using grouped inserts, and finally applying multithreaded batch processing with MyBatis, showing code examples and practical tips to reduce import time from over a minute to under ten seconds.
Streaming queries return an iterator instead of a full result set, reducing memory usage, but require the database connection to stay open; this guide explains MyBatis’s Cursor interface, its methods, common pitfalls like premature closure, and three practical solutions using SqlSessionFactory, TransactionTemplate, or @Transactional to ensure reliable streaming.
The article details Meituan's internal Sonic IDEA plugin for remote and local hot deployment, explaining why hot deployment is needed, its architecture, instrumentation techniques, DCEVM integration, file‑watching, class reloading, and support for Spring Bean, Spring XML and MyBatis, along with adoption statistics and performance benefits.
This article explains what streaming queries are, why they save memory compared to pagination, details the MyBatis Cursor interface and its methods, demonstrates how to implement streaming queries with code examples, and presents three solutions—using SqlSessionFactory, TransactionTemplate, and @Transactional—to keep the database connection open and prevent cursor‑closed errors.
This article explains how to design a MySQL table for product sales statistics and compares several query strategies—including loop queries, OR concatenation, mixed filtering, and the SQL‑92 row‑comparison technique—to efficiently retrieve sales data for multiple business units and their associated products in a single indexed query.
This article explains how MyBatis streaming queries work via the Cursor interface, why keeping the database connection open is essential, and presents three practical solutions—using SqlSessionFactory, TransactionTemplate, or @Transactional—to correctly handle streaming data in Spring applications.
This article introduces mybatis-mate, an official MyBatis‑Plus extension that provides enterprise‑grade features such as sharding, multi‑datasource support, data auditing, field encryption, sensitive‑data masking, automatic DDL maintenance, dynamic datasource switching, distributed transaction logging, and fine‑grained data permission control, with detailed usage examples and configuration snippets for Spring Boot projects.
This article walks through how MyBatis parses the transaction manager factory from XML configuration, builds the Environment, and applies the transaction manager during SqlSession creation, including detailed code examples of XMLConfigBuilder, transaction factories, and the JdbcTransaction implementation.
To overcome export failures when report data exceeds ten thousand rows, this guide demonstrates how to configure MyBatis for forward-only streaming reads by adjusting JDBC settings, adding ResultHandler callbacks, and modifying mapper XML, enabling efficient memory usage during large result set processing.
This article demonstrates how to automatically encrypt sensitive fields such as ID numbers and phone numbers before storing them in a database and decrypt them after retrieval by leveraging MyBatis plugins, custom annotations, and Spring Boot components, providing a clean, reusable solution for backend applications.
An in‑depth guide shows how running 100 concurrent MyBatis queries triggers a ClassCastException, explains the underlying cache placeholder issue, and demonstrates how Spring Boot’s SqlSessionTemplate and transaction management guarantee thread‑safe SqlSession usage through ThreadLocal binding.
This article provides a comprehensive overview of MyBatis, detailing its three‑layer architecture, core modules such as caching, reflection, and transaction management, as well as the complete execution process from configuration files to SQL execution, helping developers master the framework for enterprise‑level Java applications.
Discover the MyBatis Generator GUI tool that streamlines Java POJO and mapping file creation, outlines its six key features, system requirements, and three easy startup methods—including self‑build, IDE launch, and native packaging—so you can quickly generate MyBatis code.
This article explains MyBatis's first‑level and second‑level caching mechanisms, demonstrates data inconsistency problems caused by joined‑table queries, and provides a custom annotation‑driven relation cache solution with code examples for configuring and validating the cache behavior.
This article analyzes why MyBatis foreach‑based batch inserts become extremely slow with thousands of rows, explains the underlying SQL and PreparedStatement overhead, and demonstrates how switching to ExecutorType.BATCH or limiting foreach values to 20‑50 rows dramatically improves MySQL insertion performance.
This article explains how MyBatis' ${} and #{} placeholders differ in SQL generation, demonstrates their usage with code examples, analyzes the SQL injection risks of ${} versus the safety of #{} through prepared statements, and provides practical guidelines for choosing the appropriate placeholder in various scenarios.
This article demonstrates how to securely store and retrieve sensitive user data such as phone numbers in a MySQL database by creating a custom MyBatis TypeHandler that automatically encrypts values on insert and decrypts them on query, complete with code examples and configuration steps.
This article explains MyBatis dynamic SQL, covering its purpose, the distinction between static and dynamic SQL, the core SqlNode and SqlSource classes, how MyBatis parses and assembles SQL scripts recursively, and provides concrete code examples to illustrate each step.
This article demonstrates how to protect sensitive user data such as phone numbers in a MySQL database by creating a custom MyBatis TypeHandler that automatically encrypts values on insert and decrypts them on query using AES encryption from the Hutool library.
This article explains how MyBatis' ${} and #{} placeholders differ in syntax substitution and security, demonstrates their usage with DAO interfaces, Mapper XML, and JUnit tests, analyzes SQL injection risks, shows the underlying PreparedStatement handling, and provides practical guidelines for when to use each placeholder.
This article demonstrates how to securely store and retrieve sensitive fields such as phone numbers in a MySQL database by creating a custom MyBatis TypeHandler that encrypts data on insert and decrypts it on query, including full implementation code and configuration steps.
This article presents a complete backend implementation of a medical appointment management system, describing user roles, environment setup, technology stack, and providing full Java service and controller code for doctor, admin, and login functionalities.
This article explains why MyBatis batch inserts using a foreach loop can become extremely slow when inserting thousands of rows, analyzes the underlying cost of parsing large prepared statements, and presents practical solutions such as using ExecutorType.BATCH, limiting foreach batch size, and employing JDBC batch execution to achieve sub‑second performance.