- NHibernate Transactions: Transaction Interface
- NHibernate Transactions: Transaction Isolation Levels
- NHibernate Transactions: Transaction Locking
The ITransaction interface provides methods for declaring the boundaries of a database transaction.
The BeginTransaction() method of the Persistent Manager (ISession) is invoked to begin a database transaction.
The Commit() method of the Persistent Manager (ISession) commits the underlying transaction, and NHibernate sychronizes the Session state with the database. This process is called flushing.
NHibernate doesn't flush before every query, but if changes are held in memory that would affect the results of the query, NHibernate will, by default, synchronize first.
NHibernate defines the Persistent Manager (ISession) FlushMode property to control the flush behaviour.
|Property Value||Property Description|
|FlushMode.Auto||Default. If changes are held in memory that would affect the results of a query, NHibernate will synchronize state with the database.|
|FlushMode.Commit||NHibernate won't flush the session before query execution. This could result in modifications made to objects in memory conflicting with the results of the query.|
|FlushMode.Never||NHibernate will only synchronize state with the database when an explicit call to the Flush() method is invoked.|
It is generally not recommended to change this setting from the default.