I need to know, whether the Hibernate\'s session is thread safe or not. But obvious a new session is attached to every thread for execution. But my question is if in one thr
The Session object was designed to be used by a single thread. Internally, the Session uses many non-thread-safe data structures so it’s impossible to make it thread-safe.
More, you shouldn’t even need to use a thread-safe Session . If your use case is to share the cached entities, then you should use the second-level cache instead which is thread-safe and can be used in a clustered environment.
That being said, the need for having a thread-safe Session is a code smell indicating a flaw in the design of the data access layer.