Package org.springframework.orm.hibernate3

Examples of org.springframework.orm.hibernate3.SessionHolder


        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

    public void setUp() throws Exception {
        dataSource = new DriverManagerDataSource("jdbc:h2:mem:hibernate;DB_CLOSE_DELAY=-1", "sa", "sa");

        System.setProperty("hibernate.dialect", H2Dialect.class.getName());
        System.setProperty("hibernate.hbm2ddl.auto", "create-drop");
        AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
        sessionFactory.setDataSource(dataSource);
        sessionFactory.setAnnotatedClasses(new Class[] {PhotoSpot.class});
        sessionFactory.afterPropertiesSet();

        repo.hibernate = new HibernateTemplate(sessionFactory.getObject());
    }
View Full Code Here

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

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

    finally {
      if (!participate) {
        SessionHolder sessionHolder =
            (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
        logger.debug("Closing Hibernate Session in OpenSessionInViewFilter");
        SessionFactoryUtils.closeSession(sessionHolder.getSession());
      }
    }
  }
View Full Code Here

TOP

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