Is it possible to heal exceptions that arise during saving/committing a hibernate session?
Background: We are currently updating several hundred records per session, using FluentNHibernate. Each now and then, there is a StaleException thrown because one of the records were changed by other processes. I see that the exception is giving me the Id of the record that caused trouble, so theoretically, i could try to evict/reload the object and try the modification of the object again instead of rolling back the entire hibernate transaction.
Would that work trying to call Commit a second time, or has the session become invalid because of the exception thrown?
It seems what i was trying to do is impossible; you have to use a new session if any exception occurs while flushing to database...
https://ayende.com/blog/3946/nhibernate-mapping-concurrency
Excerpt: "If the update fails because the row was updated, we will get a StaleObjectException. Like all exceptions, this will make the session ineligible for use, and you would have to create a new session to handle it."
I´ll have to redesign my process to handle every single record with a designated session.