I have two session factories one uses MS SQL Server 2008 and other
uses IBM DB2 .
My requirement is as part of a transaction i need to update both the
databases.
Here is the code i am using
using (TransactionScope scope = new TransactionScope
(TransactionScopeOption.Required))
{
Console.WriteLine("Txn ID = " +
System.Transactions.Transaction.Current.GetHashCode());
ISessionFactory nGMSessionFactory =
(ISessionFactory)ContextRegistry.GetContext().GetObject
("SessionFactory");
ISession session = nGMSessionFactory.OpenSession();
Console.WriteLine("Txn ID= " + session.Transaction.GetHashCode
());
Vechile v = session.Get<Vechile>("19UTB18508A900093");
v.GNRCOMMENTTXT = "Test two phase commit2";
session.SaveOrUpdate(v);
session.Flush();
ISessionFactory dB2SessionFactory =
(ISessionFactory)ContextRegistry.GetContext().GetObject
("DB2SessionFactory");
ISession dB2Session = dB2SessionFactory.OpenSession();
Console.WriteLine("Txn ID= " +
dB2Session.Transaction.GetHashCode());
dB2Session.Update(v);
dB2Session.Flush();
scope.Complete();
}
If run this code i am getting the exception "The operation is not
valid for the current state of the enlistment" after the call to
scope.Complete method.
If i print the HashCode of the transactions they all look different.
That means is
NHibernate not enlisting in the existing transaction?
Any help is greatly appreciated.
--
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.