8

I learned that Hibernate's session factory is said to be thread safe. Can anyone articulate on how it acts as thread safe in a web application and how all methods are synchronized or anything else ?

Raul Rene
  • 9,219
  • 9
  • 48
  • 71
Murali
  • 319
  • 2
  • 5
  • 9
  • probably this would help you: http://stackoverflow.com/questions/14411860/why-use-only-one-sessionfactory-object-per-application – Falaque Nov 29 '13 at 13:00

1 Answers1

11

The internal state of a SessionFactory is immutable. Most problems with concurrency occur due to sharing of objects with mutable state. Once the object is immutable, its internal state is setted on creation and cannot be changed. So many threads can access it concurrently and request for sessions.

However, Session is a non-threadsafe object, you cannot share it between threads.

Juliano Alves
  • 1,860
  • 3
  • 31
  • 31