Data Access Articles
7 articles about Data Access. Explore Spring Boot implementation, design, and operations across related topics.
-
How to Implement Pagination with Spring Boot + MyBatis - Choosing Between PageHelper, RowBounds, and Hand-Written LIMIT/OFFSET
Compares three approaches to paginating list APIs in Spring Boot + MyBatis (hand-written LIMIT/OFFSET, RowBounds, and PageHelper) in terms of generated SQL, count retrieval, sorting, and extra dependencies. Explains why RowBounds results in in-memory pagination, the thread-local pitfalls of PageHelper and its helperDialect setting, and how to convert to Spring Data's Pageable, all with ready-to-run code.
-
How to Use MyBatis with Spring Boot - An Implementation Guide to Mapper Definitions, Dynamic SQL, and Result Mapping
An implementation guide to integrating MyBatis into Spring Boot from scratch. It covers everything from adding the mybatis-spring-boot-starter dependency, defining Mappers using both annotation and XML notations, dynamic SQL with the if and foreach tags, mapping join results with resultMap, the safety of #{} vs ${}, and @Transactional integration—all explained with working code.
-
How to Persist enums to a Database with Spring Boot + JPA - Choosing Between @Enumerated(EnumType.STRING) and AttributeConverter
A guide to persisting enum fields to database columns with Spring Boot + JPA. Covers the difference between @Enumerated(STRING/ORDINAL), the dangers of ORDINAL, implementing an AttributeConverter for custom code values, and criteria for choosing between the two approaches, with practical examples.
-
How to Retrieve DTOs Directly with Spring Data JPA Projections - Choosing Between Interface-Based and Class-Based Projections
Learn how to SELECT only the columns you need and project them directly into DTOs/interfaces with Spring Data JPA projections. Compares interface-based, class-based (constructor), and dynamic projections through implementations, covering differences in the generated SQL, selection criteria, and pitfalls when combined with @Query.
-
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.
-
How to Implement Soft Delete with Spring Boot + JPA - Choosing Between @SQLDelete, @SQLRestriction, and Filters
Learn how to implement soft delete transparently with Spring Boot 3.x + Hibernate 6.4. We compare @SQLDelete + @SQLRestriction (formerly @Where) with @SoftDelete and @FilterDef so you can choose the right approach quickly, and cover common pitfalls such as unique constraint conflicts, restore operations, and recording who performed the deletion.
-
MyBatis vs JPA in Spring Boot - Selection Criteria and Combined Usage Patterns [With Comparison Table]
Wondering whether to choose MyBatis or JPA for your Spring Boot project? This article organizes SQL control flexibility, learning cost, performance, and maintainability in a comparison table, and explains practical decision flowcharts, the difference between #{} and ${}, and concrete configuration examples for using both together. Get all the decision criteria in one place.