Morty Taghdisi

Series

JPA in Production

A series about how JPA and Hibernate actually behave in Spring services, from entity lifecycle and transaction mechanics to performance traps and production patterns.

Reading order

  1. 01What Actually Happens When You Save an EntityMost JPA bugs trace back to not knowing what Hibernate does between your code and the database. Understanding the persistence context, entity states, dirty checking, and flush behavior is what turns JPA from a black box into something you can reason about.
  2. 02How @Transactional Really Works@Transactional works through a proxy that most developers never see. Understanding the proxy mechanism, propagation levels, and rollback rules is what separates @Transactional as a reliable tool from a source of silent production bugs.
  3. 03Fixing JPA Performance TrapsThe N+1 query problem is the most common JPA performance issue, and it is invisible until it is not. This article covers how to detect it, fix it with fetch strategies and DTO projections, and prevent regressions.
  4. 04Production-Grade @Transactional: Patterns, Testing, and MonitoringEvent listeners, retry strategies, programmatic transactions, the outbox pattern, and how to test transactional code correctly: the production patterns that separate code that works in tests from code that works under load.