Hi,
I have a scenario where I would like to use both a stored procedure (using ADO.NET) and Nhibernate to perform some data manipulation.
Is it possible to perform these activities within the same transaction:
For example,
Code:
SqlConnection conn;
SqlTransaction trans;
ISession session;
try
{
   conn = new SqlConnection(...);
   conn.open();
   trans = conn.BeginTransaction();
   // ***** STORED PROCEDURE CODE *******
   // ...(call stored procedure and do some work)...
   // ***** HIBERNATE CODE *******   
   // How do I tell hibernate to enlist itself inside the transaction created above???
   // I thought the following would work:
   session = sessionFactory.CreateSession(conn);
   session.Save(obj);
   session.Flush(); // But this fails.
   
   trans.Commit();
}
catch(Exception)
{
   // I want to rollback changes made via the stored procedure and hibernate.
   trans.Rollback();
}
finally
{
   session.close();
   conn.close();
}
I hope you can understand what I mean. Any help will be greatly appreciated.
Thanks.