Fix for hibernate sessionFactory bugs