Synchronizing the hibernate session so that multiple threads won't mess up the session transactions. In addintion to that, adding transaction begin and commit for all the calls to make all calls atomic.