No; I've pieced things together from Google - do a search for 'manage hibernate sessions' or something similar. There are a load of blog entries on how different people have gone about doing this. It seems to be the biggest single question people ask so perhaps at some point there'll be some official documentation on it.
I think many peoples' usage is slightly different from others. Creating sessions isn't expensive, so the simplest way to solve your problem would be to create a new one whenever you need one. If you need them to stick around (maybe keep a session per thread over the lifetime of the application, and connect/disconnect as you've already tried), how about (sort of psuedo code):
Code:
IDictionary<int, ISession> sessions;
ISession SessionForCurrentThread
{
get
{
if (!sessions.ContainsKey(CurrentThread.ManagedThreadId))
{
sessions[CurrentThread.ManagedThreadId] = sessionFactory.CreateSession....
}
return sessions[CurrentThread.ManagedThreadId];
}
}
You'd probably want to add some thread safety to that. HTH.