Package org.springframework.orm.hibernate

Examples of org.springframework.orm.hibernate.SessionHolder


                participate = true;
            } else {
                if (logger.isDebugEnabled())
                    logger.debug("Opening single Hibernate session in OpenSessionInViewFilter");
                session = getSession(sessionFactory);
                TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
            }

        } else if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory))
            participate = true;
        else
View Full Code Here


    }
    private void openSession() {
        SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
        Session hibSession = SessionFactoryUtils.getSession(sessionFactory, true);
        hibSession.setFlushMode(FlushMode.NEVER);
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(hibSession));
    }
View Full Code Here

        hibSession.setFlushMode(FlushMode.NEVER);
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(hibSession));
    }
    private void closeSession() {
        SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
        SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
        SessionFactoryUtils.closeSessionIfNecessary(sessionHolder.getSession(), sessionFactory);
    }
View Full Code Here

    private void openSession() {
        SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
        Session hibSession = SessionFactoryUtils.getSession(sessionFactory, true);
        hibSession.setFlushMode(FlushMode.NEVER);
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(hibSession));
    }
View Full Code Here

        closeSession();
    }

    private void closeSession() {
        SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
        SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
        SessionFactoryUtils.closeSessionIfNecessary(sessionHolder.getSession(), sessionFactory);
    }
View Full Code Here

        participate = true;
      }
      else {
        logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter");
        Session session = getSession(sessionFactory);
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
      }
    }
    else {
      // deferred close mode
      if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory)) {
        // Do not modify deferred close: just set the participate flag.
        participate = true;
      }
      else {
        SessionFactoryUtils.initDeferredClose(sessionFactory);
      }
    }

    try {
      filterChain.doFilter(request, response);
    }

    finally {
      if (!participate) {
        if (isSingleSession()) {
          // single session mode
          SessionHolder sessionHolder =
              (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
          logger.debug("Closing single Hibernate Session in OpenSessionInViewFilter");
          closeSession(sessionHolder.getSession(), sessionFactory);
        }
        else {
          // deferred close mode
          SessionFactoryUtils.processDeferredClose(sessionFactory);
        }
View Full Code Here

        // single session mode
        logger.debug("Opening single Hibernate Session in OpenSessionInViewInterceptor");
        Session session = SessionFactoryUtils.getSession(
            getSessionFactory(), getEntityInterceptor(), getJdbcExceptionTranslator());
        applyFlushMode(session, false);
        TransactionSynchronizationManager.bindResource(getSessionFactory(), new SessionHolder(session));
      }
      else {
        // deferred close mode
        SessionFactoryUtils.initDeferredClose(getSessionFactory());
      }
View Full Code Here

   * @see #setFlushMode
   */
  public void postHandle(WebRequest request, ModelMap model) throws DataAccessException {
    if (isSingleSession()) {
      // Only potentially flush in single session mode.
      SessionHolder sessionHolder =
          (SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
      logger.debug("Flushing single Hibernate Session in OpenSessionInViewInterceptor");
      try {
        flushIfNecessary(sessionHolder.getSession(), false);
      }
      catch (HibernateException ex) {
        throw convertHibernateAccessException(ex);
      }
    }
View Full Code Here

      }
    }
    else {
      if (isSingleSession()) {
        // single session mode
        SessionHolder sessionHolder =
            (SessionHolder) TransactionSynchronizationManager.unbindResource(getSessionFactory());
        logger.debug("Closing single Hibernate Session in OpenSessionInViewInterceptor");
        SessionFactoryUtils.closeSession(sessionHolder.getSession());
      }
      else {
        // deferred close mode
        SessionFactoryUtils.processDeferredClose(getSessionFactory());
      }
View Full Code Here

TOP

Related Classes of org.springframework.orm.hibernate.SessionHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.