Multiple choice technology programming languages

Is the Session threadsafe in Hibernate ?

  1. a) TRUE

  2. b) FALSE

  3. c) no matter

  4. d) none of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In Hibernate, the Session object is explicitly NOT thread-safe and is designed for use by a single thread at a time. Hibernate's documentation states that sharing a Session across threads without synchronization can cause unpredictable behavior. For concurrent access, you should use separate Session instances per thread or consider using Hibernate's SessionFactory with proper isolation. Each thread should obtain its own Session from the SessionFactory.