Write Patterns with Spring Data
Introduction This article is the second in a series about data access with Spring Data. The previous article covered transaction boundaries, isolation, locking, and handling transaction failures. This time, we’ll focus on how to structure write operations to reduce contention, avoid unnecessary database round trips, and preserve application invariants. A common approach when working with JPA is to load an entity, modify its state, and let the persistence provider synchronize the changes with the database. This is convenient and often appropriate, but it isn’t always the most efficient way to express an operation. ...