The code you indicate will be executed in as many threads as there are, at any given time, accessing that code simultaneously.
Hopefully, only one, but there is no guarantee.
In other words, the code you describe is not thread safe.
If you have the reasonable expectation that the session code might be accessed by more than one thread at a time, then it is your responsibility to make it thread safe (no Hibernate configuration trick helps you here) .
Or, at the very least, make it short and stateless enough as to reduce the chance of concurrent access.
_________________ Gonzalo Díaz
|