code: public Session currentSession() throws HibernateException {
      SessionHolder sessionHolder = SessionUtils.currentSession(this.sessionFactory);
      Session session = sessionHolder.getSession();
      // TODO what time enter into the code?
      if (TransactionSynchronizationManager.isSynchronizationActive()
          && !sessionHolder.isSynchronizedWithTransaction()) {
        TransactionSynchronizationManager.registerSynchronization(new SessionSynchronization(sessionHolder,
            this.sessionFactory));
        sessionHolder.setSynchronizedWithTransaction(true);
        // Switch to FlushMode.AUTO, as we have to assume a thread-bound Session
        // with FlushMode.MANUAL, which needs to allow flushing within the transaction.
        FlushMode flushMode = session.getFlushMode();
        if (FlushMode.isManualFlushMode(flushMode)
            && !TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
          session.setFlushMode(FlushMode.AUTO);
          sessionHolder.setPreviousFlushMode(flushMode);
        }
      }
      return session;
    }
docs: Retrieve the Spring-managed Session for the current thread, if any.