The SessionFactory.getCurrentSession() returns a session bound to a context. We don’t need to close this. We have to set hibernate.current_session_context_class to thread and then implement something like a servlet filter that opens the session. We can access that session anywhere else by using the SessionFactory.getCurrentSession().
The SessionFactory.openSession() always opens a new session that we have to flush() and close() once we are done with the operations.