Fading Coder

One Final Commit for the Last Sprint

Advanced Techniques for MyBatis Interceptors in Data Operations

Intercepting Insert Operations A common use case involves inserting data into multiple rows simultaneously during a single operation. For instance, a pllatform administrator might need to replicate data across different country-specific records. Implementation: import lombok.extern.slf4j.Slf4j; impo...

Spring Boot Data Access with MyBatis Integration

MyBatis serves as a lightweight persistence framework that decouples SQL logic from Java application code. Unlike full-featured ORM solutions, it provides granular control over database operations while eliminating boilerplate JDBC code. The framework supports dynamic SQL construction, automatic res...

Automating MyBatis Mapping Code from Database Metadata

Add the MyBatis Generator core library along with your database driver to your project dependencies: <dependencies> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <version>8.0.33</version> </dependency> <d...

Integrate MyBatis with Spring Boot to Implement Relational Database Query Operations

Database Environment Preparation Use a MySQL 8.x instance to create the required business table. You can import pre-written SQL scripts via database management tools like Navicat or DBeaver to generate the student information table, and adjust field definitions based on actual business requirements....

Parameter Binding Strategies in MyBatis: Security and Performance Implications

MyBatis provides two distinct syntaxes for injecting dynamic values into SQL statements. Consider retrieving records from an employee table based on an email address: SELECT * FROM employee WHERE email = 'alice@example.com'; To make this query dynamic, MyBatis offers two approaches: SELECT * FROM em...

Implementing a Custom MyBatis Pagination Plugin Compatible with PageHelper Capabilities

MyBatis pagination plugin PageHelper eliminates the need to embed pagination logic or parameters directly in SQL statements. Users only need to specify pagination rules before invoking DAO layer methods to automatically implement physical pagination, greatly simplifying pagination query development...

Spring Boot with MyBatis: Essential SQL Patterns Using Annotations

1. Project setup 1.1 Dependency Add MyBatis Spring Boot starter to pom.xml. <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.3.1</version> </dependency> 1.2 Data source configuratio...

Configuring MyBatis with Multiple Data Sources in Spring Boot

Confgiuring multiple databases in a single Spring Boot application with MyBatis requires defining separate DataSource, SqlSessionFactory, and SqlSessionTemplate beans per database, and mapping each mapper package to the appropriate factory/template. Maven dependencies <dependencies> <depend...

Spring Boot MyBatis with Two MySQL DataSources Using Druid

Required dependencies application.properties: define two data sources and poooling Java configuration for both data sources MyBatis mappers for each data source Controller endpoints to verify both connecsions Sample project layout and test URLs Dependencies <!-- MySQL JDBC driver --> <depe...

MyBatis ResultMap and Nested Associations

When mapping query results in MyBatis, you can choose betwean resultType and resultMap. Only one can be used in a single select. With resultType, MyBatis relies on column-to-property name matching (and aliases) to populate a target class. With resultMap, you describe exact how each column should be...