Search code examples
multithreadingnhibernatesessionthread-safetystateless-session

Is stateless session thread safe?


I know ISession is not thread safe. Is IStatelssSession also not thread safe? I guess the answer is no. I did a quick search but didn't find a reference for this.

Thanks.


Solution

  • The StatelessSessionImpl holds a ConnectionManager which holds an IDbConnection - SqlConnection is not thread-safe, so that would be no.

    Although the NH trunk code documentation does not specific whether or not it is.

    Edit: The code also shows no thread synchronization and it also holds an ITransaction.