code: public void destroy()
    {
      log.debug("Close Hibernate session factory and releases caches and database connections.");
      // access session factory through getter to have validity check
      SessionFactory sessionFactory = getSessionFactory();
      if(sessionFactory != null) {
        sessionFactory.close();
      }
    }
docs: Destroy Hibernate session factory and releases database resources.