Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

null id in "MyEntityType" entry (don't flush the Session after an exception occurs) when trying to Session.GetAll after an GenericADOException

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)

like image 776
Omu Avatar asked Feb 25 '10 07:02

Omu


1 Answers

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?

like image 99
Michael Maddox Avatar answered Nov 06 '22 11:11

Michael Maddox