Roman
Roman

Reputation: 10403

Why do I need to call ISession.Flush after ISession.Delete

Why does NHibernate require me to flush the session after I delete? It doesn't do need a flush after updating or saving.

Upvotes: 1

Views: 674

Answers (1)

Jamie Ide
Jamie Ide

Reputation: 49301

It does need to flush after updating or saving in addition to delete. Your ISession's FlushMode setting or another factor (e.g. database generated identifiers) is causing it to flush automatically. The documentation describes the conditions that cause the session to be flushed.

In my opinion the best practice is to set the FlushMode to Commit and use transactions for all database operations, including reads (this is needed for 2nd level caching).

Upvotes: 4

Related Questions