Why does NHibernate require me to flush the session after I delete? It does开发者_JAVA百科n't do need a flush after updating or saving.
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).
精彩评论