ITransactions are instantiated through ISession so I don't think this is available using default NH functionality. As an example:
Code:
ISessionFactory sessionFactory = configuration.BuildSessionFactory();
ISession session = sessionFactory.OpenSession();
ITransaction tran = session.BeginTransaction();
As you can see, the transaction is associated with a session which is associated with a database. I don't see how you'd be able to have that transaction span two distinct session objects (with connections to your distinct databases on the same instance).
Even if you had two session factories and therefore two sessions, I don't think you could get away with it. If a Commit() fails on a transaction, you are supposed to abandon the session. What happens if your first commit() on session1 works but the commit on session2 fails? Imagine:
Code:
ISession session1 = sessionFactory1.OpenSession();
ISession session2 = sessionFactory2.OpenSession();
ITransaction tran1 = session1.BeginTransaction();
ITransaction tran2 = session2.BeginTransaction();
session1.DoSomeWork();
session2.DoSomeMoreWork();
try {
tran1.Commit();
tran2.Commit();
} catch (Exception ex) {
throw ex;
}
I don't see how you'd be able to back out of the first transaction if the second one failed. If you can figure that out, then you might have a chance.
-devon