Package org.springframework.orm.hibernate4

Examples of org.springframework.orm.hibernate4.SessionHolder


  }

  @Override
  protected void tearDown() throws Exception {
    SessionFactory factory = this.getSessionFactory();
    SessionHolder sessionHolder = (SessionHolder) this.unbind(factory);
    SessionFactoryUtils.closeSession(sessionHolder.getSession());
  }
View Full Code Here


        setUpSession(sessionFactory);
    }
    public static void setUpSession(SessionFactory sessionFactory) {
        Session session = sessionFactory.openSession();
       
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
        TransactionSynchronizationManager.initSynchronization();
    }
View Full Code Here

        setUpSession(sessionFactory);
    }
    public static void setUpSession(SessionFactory sessionFactory) {
        Session session = sessionFactory.openSession();
       
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
        TransactionSynchronizationManager.initSynchronization();
    }
View Full Code Here

 
  public void endFilter() {
    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

        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)) {
View Full Code Here

  }

  public void jobToBeExecuted(JobExecutionContext context) {
    Session session = SessionFactoryUtils.getSession(sessionFactory, true);
        session.setFlushMode(FlushMode.AUTO);
    TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
    if( LOG.isDebugEnabled()) LOG.debug("Hibernate Session is bounded to Job thread");
  }
View Full Code Here

    TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
    if( LOG.isDebugEnabled()) LOG.debug("Hibernate Session is bounded to Job thread");
  }

  public void jobWasExecuted(JobExecutionContext context, JobExecutionException exception) {
    SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
        if(!FlushMode.MANUAL.equals(sessionHolder.getSession().getFlushMode())) {
            sessionHolder.getSession().flush();
        }
    SessionFactoryUtils.closeSession(sessionHolder.getSession());       
    if( LOG.isDebugEnabled()) LOG.debug("Hibernate Session is unbounded from Job thread and closed");
  }
View Full Code Here

   
    public void sessionStart() {
        if (!(TransactionSynchronizationManager.hasResource(getSessionFactory()) || SessionFactoryUtils.isDeferredCloseActive(getSessionFactory()))) {
            Session session = SessionFactoryUtils.getSession(getSessionFactory(), getEntityInterceptor(), getJdbcExceptionTranslator());
            applyFlushMode(session, false);
            TransactionSynchronizationManager.bindResource(getSessionFactory(), new SessionHolder(session));
        }
    }
View Full Code Here

            TransactionSynchronizationManager.bindResource(getSessionFactory(), new SessionHolder(session));
        }
    }
   
    public void sessionStop() {
        SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(getSessionFactory());
  SessionFactoryUtils.closeSession(sessionHolder.getSession());
    }
View Full Code Here

                participate = true;
            }
            else {
                logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter");
                session = getSession(sessionFactory);
                TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
            }
        }
        else {
            // deferred close mode
            if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory)) {
View Full Code Here

TOP

Related Classes of org.springframework.orm.hibernate4.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.