SeniorSenior (6–10 yrs)JavaSpring BootOracleAmazon
JPA dirty checking
How does JPA dirty checking work inside a transaction?
Answers use simple, clear English.
Quick interview answer
Managed entities are snapshotted by the persistence context. At flush/commit, Hibernate compares current state to the snapshot and issues UPDATEs. Detached entities are not dirty-checked until merged.
Detailed answer
Managed entities are snapshotted by the persistence context. At flush/commit, Hibernate compares current state to the snapshot and issues UPDATEs. Detached entities are not dirty-checked until merged. Understanding flush modes prevents surprising SQL ordering.
seniorarchitect#jpa#hibernate