Thursday, September 10, 2009

NHibernate and Session Flushing

We have some bad code in our application which was using same hibernate session across multiple threads. We were not flushing the session, but data was still getting saved in database.

The reason was when first thread use to save, data was in hibernate session, but when second thread was trying to read a data using same hibernate session, hibernate was flushing the data in its session, thus it was not possible to find this error from UI as first requests data even though not saved in DB, will be seen in second request because second request is going to make hibernate session flush the data as it was read data request.

No comments: