Package net.sf.hibernate

Examples of net.sf.hibernate.FlushMode


    boolean existingTransaction = SessionFactoryUtils.isSessionTransactional(session, getSessionFactory());
    if (existingTransaction) {
      logger.debug("Found thread-bound Session for HibernateTemplate");
    }

    FlushMode previousFlushMode = null;
    try {
      previousFlushMode = applyFlushMode(session, existingTransaction);
      Session sessionToExpose = (exposeNativeSession ? session : createSessionProxy(session));
      Object result = action.doInHibernate(sessionToExpose);
      flushIfNecessary(session, existingTransaction);
View Full Code Here


    }
    else {
      TransactionSynchronizationManager.bindResource(getSessionFactory(), new SessionHolder(session));
    }

    FlushMode previousFlushMode = null;
    try {
      previousFlushMode = applyFlushMode(session, existingTransaction);
      Object retVal = methodInvocation.proceed();
      flushIfNecessary(session, existingTransaction);
      return retVal;
View Full Code Here

        session.setFlushMode(FlushMode.NEVER);
      }

      if (!definition.isReadOnly() && !txObject.isNewSessionHolder()) {
        // We need AUTO or COMMIT for a non-read-only transaction.
        FlushMode flushMode = session.getFlushMode();
        if (FlushMode.NEVER.equals(flushMode)) {
          session.setFlushMode(FlushMode.AUTO);
          txObject.getSessionHolder().setPreviousFlushMode(flushMode);
        }
      }
View Full Code Here

          logger.debug("Registering Spring transaction synchronization for existing Hibernate Session");
          TransactionSynchronizationManager.registerSynchronization(
              new SpringSessionSynchronization(sessionHolder, sessionFactory, jdbcExceptionTranslator, false));
          sessionHolder.setSynchronizedWithTransaction(true);
          // Switch to FlushMode.AUTO if we're not within a read-only transaction.
          FlushMode flushMode = session.getFlushMode();
          if (FlushMode.NEVER.equals(flushMode) &&
              !TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
            session.setFlushMode(FlushMode.AUTO);
            sessionHolder.setPreviousFlushMode(flushMode);
          }
View Full Code Here

                    new SpringJtaSynchronizationAdapter(
                        new SpringSessionSynchronization(sessionHolder, sessionFactory, jdbcExceptionTranslator, false),
                        jtaTm));
                sessionHolder.setSynchronizedWithTransaction(true);
                // Switch to FlushMode.AUTO if we're not within a read-only transaction.
                FlushMode flushMode = session.getFlushMode();
                if (FlushMode.NEVER.equals(flushMode)) {
                  session.setFlushMode(FlushMode.AUTO);
                  sessionHolder.setPreviousFlushMode(flushMode);
                }
              }
View Full Code Here

   * @see net.sf.hibernate.Session#setFlushMode
   */
  protected FlushMode applyFlushMode(Session session, boolean existingTransaction) {
    if (getFlushMode() == FLUSH_NEVER) {
      if (existingTransaction) {
        FlushMode previousFlushMode = session.getFlushMode();
        if (!previousFlushMode.equals(FlushMode.NEVER)) {
          session.setFlushMode(FlushMode.NEVER);
          return previousFlushMode;
        }
      }
      else {
        session.setFlushMode(FlushMode.NEVER);
      }
    }
    else if (getFlushMode() == FLUSH_EAGER) {
      if (existingTransaction) {
        FlushMode previousFlushMode = session.getFlushMode();
        if (!previousFlushMode.equals(FlushMode.AUTO)) {
          session.setFlushMode(FlushMode.AUTO);
          return previousFlushMode;
        }
      }
      else {
        // rely on default FlushMode.AUTO
      }
    }
    else if (getFlushMode() == FLUSH_COMMIT) {
      if (existingTransaction) {
        FlushMode previousFlushMode = session.getFlushMode();
        if (previousFlushMode.equals(FlushMode.AUTO)) {
          session.setFlushMode(FlushMode.COMMIT);
          return previousFlushMode;
        }
      }
      else {
View Full Code Here

TOP

Related Classes of net.sf.hibernate.FlushMode

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.