Sql Articles
3 articles about Sql. Explore Spring Boot implementation, design, and operations across related topics.
-
How to Reuse SQL in Spring Boot + MyBatis Using sql and include Tags - Eliminating Query Duplication Across Mappers
Are you copy-pasting the same WHERE conditions or SELECT column lists across multiple Mapper XML files? This article explains how to define SQL fragments with MyBatis's sql tag and reuse them within the same Mapper or across different Mapper XML files using the include tag, how to pass parameters with property, and how to combine this with dynamic SQL tags like foreach.
-
Dynamic SQL in Spring Boot + MyBatis: How to Write where, set, trim, choose, bind, and foreach, and How to Fix "Leading AND Left Behind", "Trailing Comma", and "Empty IN Clause Crashes"
A walkthrough of Spring Boot + MyBatis dynamic SQL tags (where/set/trim/choose/bind/foreach), showing the XML you write side by side with the SQL actually issued. Covers a search Mapper that doesn't break even when every condition is empty, partial updates that never leave a trailing comma, and defensive patterns so foreach doesn't fail when given an empty list or null, organized as fixes by error type.
-
How to Execute Raw SQL with Spring Boot's JdbcTemplate - Using queryForObject, RowMapper, and Batch Updates
A hands-on, code-focused guide to safely writing raw SQL with Spring's standard JdbcTemplate, covering single-row and scalar retrieval with queryForObject, multi-row retrieval with RowMapper/BeanPropertyRowMapper, CRUD with update/batchUpdate, named parameter binding with NamedParameterJdbcTemplate, and integration with @Transactional.