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:org.springframework.orm.jpa.vendor.HibernateJpaDialect.java

License:Apache License

protected FlushMode prepareFlushMode(Session session, boolean readOnly) throws PersistenceException {
    FlushMode flushMode = session.getFlushMode();
    if (readOnly) {
        // We should suppress flushing for a read-only transaction.
        if (!flushMode.equals(FlushMode.MANUAL)) {
            session.setFlushMode(FlushMode.MANUAL);
            return flushMode;
        }//from   ww w .java  2s.  c  om
    } else {
        // We need AUTO or COMMIT for a non-read-only transaction.
        if (flushMode.lessThan(FlushMode.COMMIT)) {
            session.setFlushMode(FlushMode.AUTO);
            return flushMode;
        }
    }
    // No FlushMode change needed...
    return null;
}

From source file:org.uengine.edu.oop.soc.model.OopsocsamplePersistentManager.java

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

From source file:org.webical.web.util.WriteableOpenSessionInViewFilter.java

License:Open Source License

@Override
protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
    log.debug("returning session");
    /* Checks for a Session currently bound to the thread and creates one if not found */
    Session session = SessionFactoryUtils.getSession(sessionFactory, true);
    /* Makes the Session writable */
    session.setFlushMode(FlushMode.AUTO);

    return session;
}

From source file:org.zkoss.zkgrails.ZKGrailsOpenSessionInViewListener.java

License:Open Source License

private Session getSession() throws DataAccessResourceFailureException {
    Session session = SessionFactoryUtils.getSession(sessionFactory, true);
    session.setFlushMode(FlushMode.AUTO);
    return session;
}

From source file:orm.AdministracionContactosPersistentManager.java

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

From source file:orm.ApuestaPersistentManager.java

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

From source file:orm.AsddsapdsPersistentManager.java

private AsddsapdsPersistentManager() throws PersistentException {
    super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties,
            _configurationFile);/*from  w w  w  .  j av a  2s  . co m*/
    setFlushMode(FlushMode.AUTO);
}

From source file:orm.BDProyecto2PersistentManager.java

private BDProyecto2PersistentManager() throws PersistentException {
    super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties,
            _configurationFile);/*  ww  w.  j  a v  a  2 s  .c  om*/
    setFlushMode(FlushMode.AUTO);
}

From source file:orm.DBprueba2PersistentManager.java

private DBprueba2PersistentManager() throws PersistentException {
    super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties,
            _configurationFile);/*w ww .  j  a  v a2  s. co  m*/
    setFlushMode(FlushMode.AUTO);
}

From source file:orm.DiagramaetpmPersistentManager.java

private DiagramaetpmPersistentManager() throws PersistentException {
    super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties,
            _configurationFile);//  ww  w. jav a 2 s .  c o m
    setFlushMode(FlushMode.AUTO);
}