This is a question one of my juniors asked me and I was completely dumbstruck.
according to java docs for Hibernate :
It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.
Obtains the current session. The definition of what exactly "current" means controlled by the CurrentSessionContext impl configured for use.
So if session object is not threadsafe, what happens when two threads call sessionFactory.getCurrentSession() .... if they get the same session object will there not be chances of all the dangers that threads cause when they get the same instance?
java api of CurrentSessionContext did not help and when i browsed through the code for implementors of CurrentSessionContext, it seemed to me that it is returning the same session object.
Please help, this has been bugging me for some time now.