JPA Articles
Articles covering JPA relationship mapping, query methods, transactions, and performance optimization for data access design.
-
How to Automate Entity-DTO Mapping with MapStruct in Spring Boot
An implementation guide for auto-generating toDto()/toEntity() methods with MapStruct instead of writing them by hand. Covers adding dependencies, basic @Mapper usage, nested objects, custom conversions, and unit testing.
-
Implementing CRUD REST API with Spring Boot - Basic Structure of Controller, Service, and Repository
A step-by-step guide to implementing CRUD (Create, Read, Update, Delete) REST API with Spring Boot. Build the three-layer architecture of Controller, Service, and Repository from scratch, and walk through setting up all four endpoints: GET, POST, PUT, and DELETE.
-
How to Automatically Record Created and Updated Timestamps with JPA Auditing in Spring Boot
A guide to automatically recording entity creation and update timestamps using JPA Auditing in Spring Boot. Covers practical code for configuring @CreatedDate, @LastModifiedDate, @EnableJpaAuditing, and AuditorAware, including integration with Spring Security.
-
Which Should You Choose in Spring Boot: MyBatis or JPA? - Selection Criteria and Combined Usage Patterns
Are you unsure whether to choose MyBatis or JPA for your Spring Boot project? This article provides a thorough comparison of both from the perspectives of SQL control flexibility, learning cost, and maintainability, and presents practical selection criteria such as JPA for CRUD-focused use cases and MyBatis for complex reporting screens. Also covers how to implement a combined usage pattern.
-
Understanding Transaction Management with @Transactional in Spring Boot - How to Use Propagation Levels and Isolation Levels
A comprehensive guide to transaction management using the @Transactional annotation in Spring Boot, from basics to practical usage. Covers default behavior, all 7 propagation levels, 4 isolation levels, and common failure patterns where rollback does not work (checked exceptions, self-invocation) with real examples.
-
Spring Data JPA Query Methods: Naming Conventions and Examples
Master Spring Data JPA query method naming conventions — findBy, existsBy, countBy, and more. Covers multiple conditions, sorting, pagination, and @Query with practical examples.
-
How to Map Entity Relationships with JPA in Spring Boot - Using @OneToMany and @ManyToOne
A beginner-friendly guide to correctly mapping relationships between entities (@OneToMany, @ManyToOne, @ManyToMany) with JPA in Spring Boot. Covers the differences between bidirectional and unidirectional associations, cascade configuration, choosing FetchType, and practical approaches to avoiding the N+1 problem and circular references.