Hello,
ISessionFactory MySF1 ; // for a database X
ISessionFactory MySF2 ;// for an another database Y
ISession session1= MySF1 .OpenSession();
ISession session2= MySF2 .OpenSession();
CurrentSessionContext.Bind(sessionFromMySF1);
//Transaction begins
…
Somewhere else in a function I can get the current session like this: “MySF1.GetCurrentSession()”
…
//Transaction ends
MySF1 .Unbind(MySF1);
I can use several SessionFactory if I want to use multiple DB.
Why GetCurrentSession is called from the object SessionFactory while CurrentSessionContext.Bind is done with a session?
I would like to have a currentSession by sessionFactory because if I do this:
CurrentSessionContext.Bind (sessionFromMySF1);
CurrentSessionContext.Bind (sessionFromMySF2);
This is the last line prevails: "MySF1.GetCurrentSession ()" and "MySF2.GetCurrentSession ()" return both the session for database Y
The documentation is not very clear, could you help me on this point.
Thank you
|