Currently I am working on a project, that was programmed by someone else and it is known that the NHibernate part might not be well implemented. I was asked to improve that during my internship, but I am also very new to NHibernate.
I came across some code parts where there was a Flush after a select, in my opinion that is completely useless, am I right (question 1)?
I read almost the complete NHibernate Documentation but I am not sure I understand everything.
Should I flush before a select (question 2)? My thoughts are that the data would be up to date when I select after a flush.
(Currently the program doesn’t use any transactions at all – I see a lot of room for improvement there)
NH Official documents say:
You should always use transactions, even for a read.
If you’re not using transaction you should use Flush after a write.
It doesn’t really make sens to Flush after a read.
Have a look a these two answers where everything is explained very well.