MyBatis Caching: First-Level, Second-Level, and EHCache Integration

Understanding MyBatis Caching Mechanisms MyBatis incorporates an internal caching system designed to enhance application performance by minimizing redundant database interactions. This caching operates at two distinct levels: a local, session-scoped cache and a global, application-scoped cache. First-Level Cache: SqlSession Scope The first-leve ...

Posted on Wed, 20 May 2026 16:32:32 +0000 by Jackount

Spring Boot Persistence with MyBatis

MyBatis is a lightweight SQL-mapping framweork that removes most JDBC boiler-plate while still giving full control over SQL. The following walkthrough shows how to integrate it into a Spring Boot project and perform common CRUD operations. Project bootstrap and data source configuration Create a new Spring Boot project with the spring-boot- ...

Posted on Wed, 20 May 2026 08:09:11 +0000 by AceE

Using Redis Caching in MyBatis Operations with Spring Boot

In the previous article, we explored Spring Boot integration with Redis. This article focuses on implementing Redis caching in MyBatis operations. We'll examine four key annotations: @CachePut, @Cacheable, @CacheEvict, and @CacheConfig. Fundamentals @Cacheable The @Cacheable annotation configures method-level caching, storing results based on m ...

Posted on Wed, 20 May 2026 07:19:39 +0000 by santhosh_89

Implementing MyBatis XML ResultMap for Entity Associations

Relational database interactions often involve navigating relationships between tables. In MyBatis, the <resultMap> element provides a robust mechanism to map these relationships—One-to-One, One-to-Many, and Many-to-Many—directly to Java object graphs. This process relies heavily on the <association> and <collection> tags wit ...

Posted on Tue, 19 May 2026 05:08:37 +0000 by Bill H

MyBatis Parameter Handling Techniques

Passing Parameters in MyBatis MyBatis provides multiple ways to pass parameters from Java code to XML mapper files. This article explores several common techniques used in parameter handling. Single Simple Parameter When a DAO interface method has a single simple paraemter (such as a primitive type or String), you can use any placeholder name i ...

Posted on Mon, 18 May 2026 22:51:41 +0000 by Hatch

Getting Started with MyBatis

<groupId>org.example</groupId> <artifactId>A01mybatis</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <!-- MyBatis dependency --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3 ...

Posted on Mon, 18 May 2026 18:14:24 +0000 by CBG

MyBatis Source Code Analysis: Mapper Proxy Mechanism

In earlier versions of MyBatis, developers could invoke database operations directly through the DefaultSqlSession's selectOne() method using the StatementID defined in Mapper XML files. This approach, while functional, presented significant maintainability challenges. The StatementID was specified as a hardcoded string constant, making refacto ...

Posted on Mon, 18 May 2026 18:03:21 +0000 by bidnshop

Implementing One-to-One Mappings in MyBatis

Database Schema Setup Create tables for identity cards and students, where each student references one card via a foreign key. CREATE TABLE identity_cards ( card_id INT PRIMARY KEY, card_number VARCHAR(20) ); CREATE TABLE students ( student_id INT PRIMARY KEY, student_name VARCHAR(10), card_ref INT, FOREIGN KEY (card_re ...

Posted on Sun, 17 May 2026 20:36:52 +0000 by guru2k9

Understanding MyBatis's Core Execution Flow and Internal Architecture

Resource Loading via ClassLoader The process begins with loading the configuration file, typically mybatis.xml, using Resources.getResourceAsStream(). This method leverages Java’s class loading mechanism to locate resources within the classpath. It does not resolve absolute file paths directly but instead relies on the ClassLoader hierarchy to ...

Posted on Sun, 17 May 2026 00:51:05 +0000 by XeroXer

Implementing Persistence with MyBatis and MyBatis-Plus: A Technical Overview

Understanding MyBatis Core Concepts MyBatis operates as a first-class persistence framework that simplifies database interaction by coupling SQL statements with Java objects. It abstracts the complexities of manual JDBC coding, including resource management and result set extraction. By utilizing XML descriptors or annotations, developers map p ...

Posted on Sat, 16 May 2026 12:39:47 +0000 by o3d