I catch the GenericADOException with InnerException.Message = "Unique key violation ...", for telling the user that the login entered is already in use.
after that I'm trying to get some date (Session.CreateCriteria) i get this error:
null id in "MyEntityType" entry (don't flush the Session after an exception occurs)
views:
113answers:
1
+2
A:
http://www.nhforge.org/doc/nh/en/index.html#manipulatingdata-exceptions
If the ISession throws an exception you should immediately rollback the transaction, call ISession.Close() and discard the ISession instance. Certain methods of ISession will not leave the session in a consistent state.
Did you throw away the session after the exception and start a fresh session?
Michael Maddox
2010-02-25 10:02:20
if I do Session.Clear() after the exception was thrown than I'm not going to have this problem, but I don't think that is a good idea to clear the Session for the entire webapp because of a single user that got an exception
Omu
2010-02-25 10:09:37
You must close the session after an exception. I would suggest you rewrite your app to first query for the login before trying to insert it so you can get the same functionality without a database exception being thrown. It appears that you are currently getting an exception in a non-exceptional situation due to your implementation choices. Also, it's a best practice to have a session per web request, not a session per web app.
Michael Maddox
2010-02-25 10:17:42