What is dirty checking? How is flush different from commit?
Short answer
Dirty checking: Hibernate snapshots an entity at load, compares at flush and generates the UPDATE itself. Flush sends SQL but stays inside the transaction; commit makes it final.
3 points to say:
- A managed entity you change is updated automatically.
- Flush is not commit: after a flush you can still roll back.
- Read-only work uses
readOnlyto stay light.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.