How a JPA save() Call Silently Overwrote My Data (and How to Fix It)
How a JPA save() Call Silently Overwrote My Data (and How to Fix It) I recently encountered a subtle but dangerous issue in a Spring Boot + JPA application. There were no errors, no exceptions, and no failed transactions — yet a database column was silently overwritten with NULL . If you are using Spring Data JPA and updating the same table from multiple endpoints, this is something you should be aware of. The Simplified Scenario We had two REST endpoints updating the same entity, but different fields. The code below is simplified and mangled for illustration. Endpoint A – updates an external reference EntityX entity = repository.findByKey(refId); // update external reference entity.setExternalRef("ABC123"); repository.save(entity); Endpoint B – updates customer email EntityX entity = repository.findByKey(refId); // update email only entity.setEmail("user@example.com"); repository.save(entity); The assumption was that Endpoint B would ...