Data Access Articles
4 articles about Data Access. Explore Spring Boot implementation, design, and operations across related topics.
-
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 Filter
This article explains how to transparently implement soft delete (logical deletion) with Spring Boot 3.x + Hibernate 6.4. It organizes a comparison between @SQLDelete + @SQLRestriction (formerly @Where) and @SoftDelete / @FilterDef so you can quickly choose the right approach, and summarizes common pitfalls such as unique constraint conflicts, restoration handling, and recording who deleted the record.
-
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.