intermediateThe Persistence Context — First-Level Cache, Dirty Checking & Flush

What's the difference between a flush and a commit?

A flush executes the pending SQL (INSERTs/UPDATEs/DELETEs) needed to sync the persistence context's state to the database, but doesn't make those changes permanently visible to other transactions — a flushed-but-uncommitted change is still fully rollback-able. A commit is what actually finalizes the transaction, making its effects (already flushed) permanently visible to others.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.

What's the difference between a flush and a commit?

Next Step

Continue to Why can a long-running batch job that processes thousands of entities in one transaction run into memory problems?← Back to all Spring Data JPA & Hibernate Mastery questions