Example usage for org.hibernate FlushMode AUTO

List of usage examples for org.hibernate FlushMode AUTO

Introduction

In this page you can find the example usage for org.hibernate FlushMode AUTO.

Prototype

FlushMode AUTO

To view the source code for org.hibernate FlushMode AUTO.

Click Source Link

Document

The Session is sometimes flushed before query execution in order to ensure that queries never return stale state.

Usage

From source file:StatementSQLPersistentManager.java

private StatementSQLPersistentManager() throws PersistentException {
    super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties,
            _configurationFile);//from w ww  . j  ava2s  . co  m
    setFlushMode(FlushMode.AUTO);
}

From source file:Gestiƃ.java

    private GestinEconmicaConstructoraPersistentManager() throws PersistentException {
   super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties, _configurationFile);
   setFlushMode(FlushMode.AUTO);
}

From source file:bbdd.ProyectoNuevoPersistentManager.java

private ProyectoNuevoPersistentManager() throws PersistentException {
    super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties,
            _configurationFile);/*from w w  w  . j  ava 2s  .c  o  m*/
    setFlushMode(FlushMode.AUTO);
}

From source file:br.mdarte.exemplo.academico.cd.CursoAbstract.java

public static CursoAbstract getEntityFromTO(br.mdarte.exemplo.academico.to.CursoTO to) throws Exception {
    AbstractDAO.currentSession().setFlushMode(FlushMode.NEVER);
    CursoAbstract entity = (CursoAbstract) AbstractEntity.getEntityInstanceFromTO(to, new java.util.HashMap());
    AbstractDAO.currentSession().setFlushMode(FlushMode.AUTO);
    return entity;

}

From source file:br.mdarte.exemplo.academico.cd.EstudanteAbstract.java

public static EstudanteAbstract getEntityFromTO(br.mdarte.exemplo.academico.to.EstudanteTO to)
        throws Exception {
    AbstractDAO.currentSession().setFlushMode(FlushMode.NEVER);
    EstudanteAbstract entity = (EstudanteAbstract) AbstractEntity.getEntityInstanceFromTO(to,
            new java.util.HashMap());
    AbstractDAO.currentSession().setFlushMode(FlushMode.AUTO);
    return entity;

}

From source file:classes.UntitledPersistentManager.java

private UntitledPersistentManager() throws PersistentException {
    super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties,
            _configurationFile);// www  .  j  a va2s. c  o  m
    setFlushMode(FlushMode.AUTO);
}

From source file:com.abiquo.abiserver.persistence.hibernate.HibernateDAOFactory.java

License:Open Source License

@Override
public void beginConnection(final boolean readOnly) {
    if (readOnly) {
        getSessionFactory().getCurrentSession().setFlushMode(FlushMode.MANUAL);
    } else {/* w  w w. j a v a 2  s .c  o  m*/
        getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO);
    }
    getSessionFactory().getCurrentSession().beginTransaction();
}

From source file:com.abiquo.abiserver.persistence.hibernate.HibernateUtil.java

License:Open Source License

public static Session getSession(final boolean ro) {
    if (ro) {/*from w ww  .  j av a  2  s  .c  om*/
        sessionFactory.getCurrentSession().setFlushMode(FlushMode.MANUAL);
    } else {
        sessionFactory.getCurrentSession().setFlushMode(FlushMode.AUTO);
    }
    return sessionFactory.getCurrentSession();
}

From source file:com.astonish.dropwizard.routing.hibernate.RoutingUnitOfWorkRequestDispatcherTest.java

License:Apache License

@Before
public void setUp() throws Exception {
    when(unitOfWork.readOnly()).thenReturn(false);
    when(unitOfWork.cacheMode()).thenReturn(CacheMode.NORMAL);
    when(unitOfWork.flushMode()).thenReturn(FlushMode.AUTO);
    when(unitOfWork.transactional()).thenReturn(true);

    when(sessionFactory.openSession()).thenReturn(session);
    when(session.getSessionFactory()).thenReturn(sessionFactory);
    when(session.beginTransaction()).thenReturn(transaction);
    when(session.getTransaction()).thenReturn(transaction);

    when(context.getRequest()).thenReturn(requestContext);

    when(transaction.isActive()).thenReturn(true);

    mockStatic(RouteStore.class);
    when(RouteStore.getInstance()).thenReturn(routeStore);
    when(routeStore.getRoute()).thenReturn("factory");
}

From source file:com.bloatit.data.DataManager.java

License:Open Source License

/**
 * Open a transaction (Or a "work unit"). Tells to the data layer that some
 * work will be done. You can change the beaver of the current transaction
 * using {@link #setReadOnly()}/*from w  w w  .ja v  a 2s  .co  m*/
 * <p>
 * You cannot open 2 transactions in the same thread. Make sure you have
 * called {@link #close()} before.
 * </p>
 */
public static void open() {
    final Session session = SessionManager.getSessionFactory().getCurrentSession();
    SessionManager.beginWorkUnit();
    session.setDefaultReadOnly(false);
    session.setFlushMode(FlushMode.AUTO);
}