In simple terms:
- Similarity: after both
flush
andcommit
, later queries will be able to retrieve these changes. - Difference:
flush()
changes are in a pending state (no db statements are issued yet), and can be undone byrollback()
; commits are persisted to db and non-reversible.
Why use flush:
- To have atomicity–making sure that a group of transactions either all succeed or all fail.