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

Configuring JDBC and Druid Data Sources in Spring Boot

Project Dependencies for Standard JDBC To configure a data source using Spring Boot's default JDBC support, typically backed by Tomcat JDBC, include the folllowing dependencies in your Maven pom.xml file. This configuration also integrates MyBatis for database mapping. <dependencies> <dependency> <groupId>org.sprin ...

Posted on Fri, 15 May 2026 07:30:52 +0000 by guttyguppy

Eliminating Mapper XML Files with MyBatis Generic Mapper

Overview Generic Maper removes the need for manual mapper XML configuration files. In most scenarios, you don't even need to define custom mapper interface methods, which dramatically improves development productivity. Dependency Configuration For version 3.1.0 and later, use the following Maven dependency: <dependency> <groupId&gt ...

Posted on Fri, 15 May 2026 05:47:11 +0000 by Ansel_Tk1