Hello,
I am kind of confused on how Flush ( and NHibernate.ISession) in NHibernate works.
From my code, it seems that when I saved an object by using ISession.Save(entity), the object can be saved directly to the database.
However, when I update and object using ISession.SaveOrUpdate(entity) or ISession.Update(entity), the object in the database is not updated--- I need to call ISession.Flush in order to update it.
The procedure on how I update the object is as follows:
- Obtain the object from the database by using
ISession.Get(typeof(T), id) - Change the object property, for example,
myCar.Color="Green" - Commit it back to the database by using
ISession.Update(myCar)
The myCar is not updated to database. However, if I call ISession.Flush afterwards, then it is updated.
When to use Flush, and when not to use it?