if (isSessionBoundToThread() && sessionBoundToThread().isConnected())
Session session = nullOrSessionBoundToThread(); if ( session != null && session.isConnected())
    private void disconnectSession() throws HibernateException    {        if (isSessionBoundToThread() && sessionBoundToThread().isConnected())        {            debug("Session bound to thread. Disconnecting.");            sessionBoundToThread().disconnect();        } else {            debug("No session bound to thread. Can't disconnect.");        }            }