Hi
As part of an application that I am developing I have encountered an
issue with the ISession object that I just can't resolve. The basic
issue occurs when I attempt to write an audit entry after some some
database processing throws an exception. I understand that when an
exception is thrown I need to discard the current open session but
when I attempt to create a new session and access the database I am
getting an error thrown.
This snippet of code illistrates the basic problem:
ISessionFactory factory = new Configuration().Configure
().BuildSessionFactory();
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
transaction.Rollback();
}
}
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
transaction.Commit();
}
}
When the second attempt to open the transaction is made the following
exception is thrown:
NHibernate.ADOException: cannot open connection --->
System.Transactions.TransactionAbortedException: The transaction has
aborted. ---> System.Transactions.TransactionPromotionException:
Failure while attempting to promote transaction. --->
System.Data.SqlClient.SqlException: The PROMOTE TRANSACTION request
failed because there is no local transaction active..
Can anyone identify what I am doing wrong?
Thanks
Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---