My understanding of what happens when an execption is thrown from
within the ISession instance is the "the session is left in an
inconsistent and undefined state" per the docs which I have aways
taken to mean that you basically shouldn't call
session.<anything>(...) on it after an exception is thrown.
Throw away (destroy) the session object from within which the
exception was thrown and use SessionFactory to open another new
session (return a new ISession instance entirely) to do anything
else. Closing the session instance and trying to start again with
more operations from within that same original session instance isn't
allowed since by definition the 'state of the session is not
consistent'. No amount of .Close(...) or anything else will return
the session instance to a known-good state and this is why all other
tests after your initial exception will always fail in this context.
> > NHibernate.Event.Default.DefaultFlushEntityEventListener.OnFlushEntity(FlushEntityEvent
> > event) in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Event\Default
> > \DefaultFlushEntityEventListener.cs: line 36
> > at
>
> > NHibernate.Event.Default.AbstractFlushingEventListener.FlushEntities(FlushEvent
> > event) in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Event\Default
> > \AbstractFlushingEventListener.cs: line 163
> > at
>
> > NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent
> > event) in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Event\Default
> > \AbstractFlushingEventListener.cs: line 61
> > at
> > NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
> > event) in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Event\Default
> > \DefaultFlushEventListener.cs: line 18
> > at NHibernate.Impl.SessionImpl.Flush() in c:\CSharp\NH2.0.0\nhibernate
> > \src\NHibernate\Impl\SessionImpl.cs: line 1186
> > at NHibernate.Transaction.AdoTransaction.Commit() in c:\CSharp
> > \NH2.0.0\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs: line
> > 177
> > at CBMapping.Data.NHibernate.NHibernateDAL.CommitTransaction(Boolean
> > closeSession) in NHibernateDAL.cs: line 296
> > at CBMapping.Data.NHibernate.NHibernateDAL.CommitTransaction() in
> > NHibernateDAL.cs: line 319
> > at
> > CBMapping.MOS6.Data.UnitTests.CrudTests.OfficeGroup_CrudTest.Create()
> > in OfficeGroup_CrudTest.generated.cs: line 65- Hide quoted text -
>
> - Show quoted text -