Package org.hibernate

Examples of org.hibernate.FlushMode


          TransactionSynchronizationManager.registerSynchronization(
              new SpringSessionSynchronization(sessionHolder, sessionFactory, jdbcExceptionTranslator, false));
          sessionHolder.setSynchronizedWithTransaction(true);
          // Switch to FlushMode.AUTO, as we have to assume a thread-bound Session
          // with FlushMode.NEVER, which needs to allow flushing within the transaction.
          FlushMode flushMode = session.getFlushMode();
          if (flushMode.lessThan(FlushMode.COMMIT) &&
              !TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
            session.setFlushMode(FlushMode.AUTO);
            sessionHolder.setPreviousFlushMode(flushMode);
          }
        }
View Full Code Here


                        new SpringSessionSynchronization(sessionHolder, sessionFactory, jdbcExceptionTranslator, false),
                        jtaTm));
                sessionHolder.setSynchronizedWithTransaction(true);
                // Switch to FlushMode.AUTO, as we have to assume a thread-bound Session
                // with FlushMode.NEVER, which needs to allow flushing within the transaction.
                FlushMode flushMode = session.getFlushMode();
                if (flushMode.lessThan(FlushMode.COMMIT)) {
                  session.setFlushMode(FlushMode.AUTO);
                  sessionHolder.setPreviousFlushMode(flushMode);
                }
              }
            }
View Full Code Here

  public Object prepareTransaction(EntityManager entityManager, boolean readOnly, String name)
      throws PersistenceException {

    Session session = getSession(entityManager);
    FlushMode flushMode = session.getFlushMode();
    FlushMode previousFlushMode = null;
    if (readOnly) {
      // We should suppress flushing for a read-only transaction.
      session.setFlushMode(FlushMode.MANUAL);
      previousFlushMode = flushMode;
    }
View Full Code Here

  @Override
  public Object prepareTransaction(EntityManager entityManager, boolean readOnly, String name)
      throws PersistenceException {

    Session session = getSession(entityManager);
    FlushMode flushMode = session.getFlushMode();
    FlushMode previousFlushMode = null;
    if (readOnly) {
      // We should suppress flushing for a read-only transaction.
      session.setFlushMode(FlushMode.MANUAL);
      previousFlushMode = flushMode;
    }
View Full Code Here

        TransactionSynchronizationManager.registerSynchronization(
            new SpringSessionSynchronization(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);
        }
View Full Code Here

        session.setFlushMode(FlushMode.MANUAL);
      }

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

          TransactionSynchronizationManager.registerSynchronization(
              new SpringSessionSynchronization(sessionHolder, sessionFactory, jdbcExceptionTranslator, false));
          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.lessThan(FlushMode.COMMIT) &&
              !TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
            session.setFlushMode(FlushMode.AUTO);
            sessionHolder.setPreviousFlushMode(flushMode);
          }
        }
View Full Code Here

                        new SpringSessionSynchronization(sessionHolder, sessionFactory, jdbcExceptionTranslator, false),
                        jtaTm));
                sessionHolder.setSynchronizedWithTransaction(true);
                // Switch to FlushMode.AUTO, as we have to assume a thread-bound Session
                // with FlushMode.NEVER, which needs to allow flushing within the transaction.
                FlushMode flushMode = session.getFlushMode();
                if (flushMode.lessThan(FlushMode.COMMIT)) {
                  session.setFlushMode(FlushMode.AUTO);
                  sessionHolder.setPreviousFlushMode(flushMode);
                }
              }
            }
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.lessThan(FlushMode.COMMIT)) {
          session.setFlushMode(FlushMode.AUTO);
          txObject.getSessionHolder().setPreviousFlushMode(flushMode);
        }
      }
View Full Code Here

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

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

TOP

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