Example usage for org.hibernate FlushMode COMMIT

List of usage examples for org.hibernate FlushMode COMMIT

Introduction

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

Prototype

FlushMode COMMIT

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

Click Source Link

Document

The Session is flushed when Transaction#commit is called.

Usage

From source file:br.com.gauge.hibernate.impl.HibernatePersistenceContext.java

License:Creative Commons License

public HibernatePersistenceContext() {
    session = factory.openSession();
    session.setFlushMode(FlushMode.COMMIT);
    trans = session.beginTransaction();
    trans.setTimeout(TRANSACTION_TIMEOUT);
}

From source file:com.adsapient.shared.service.AdSapientHibernateService.java

License:Open Source License

public static synchronized Session openSession() throws HibernateException {
    if (sessionFactory == null) {
        return null;
    }/*w w  w  .  ja  v  a2  s . c om*/

    if (testSession != null) {
        return testSession;
    }

    Session session = sessionFactory.openSession();
    session.setFlushMode(FlushMode.COMMIT);

    return session;
}

From source file:com.cimmyt.model.dao.impl.AbstractDAO.java

License:Apache License

public void deleteWithOutSession(T persistentObject) {
    getHibernateTemplate().getSessionFactory().getCurrentSession().setFlushMode(FlushMode.COMMIT);
    getHibernateTemplate().delete(persistentObject);
    getHibernateTemplate().getSessionFactory().getCurrentSession().flush();
}

From source file:com.cimmyt.model.dao.impl.AbstractDAO.java

License:Apache License

public void updateWithoutSession(T transientObject) {
    getHibernateTemplate().getSessionFactory().getCurrentSession().setFlushMode(FlushMode.COMMIT);
    getHibernateTemplate().saveOrUpdate(transientObject);
    getHibernateTemplate().getSessionFactory().getCurrentSession().flush();
}

From source file:com.db4o.drs.hibernate.impl.HibernateReplicationProvider.java

License:Open Source License

public HibernateReplicationProvider(Configuration cfg, String name) {
    _name = name;/*  w  w w .j a  v a2s  .  com*/
    _cfg = ReplicationConfiguration.decorate(cfg);

    if (SHOW_SQL) {
        _cfg.setProperty("hibernate.show_sql", "true");
    }

    new TablesCreatorImpl(_cfg).validateOrCreate();

    _cfg.setInterceptor(EmptyInterceptor.INSTANCE);

    EventListeners el = _cfg.getEventListeners();
    el.setFlushEventListeners(
            (FlushEventListener[]) Util.add(el.getFlushEventListeners(), _flushEventListener));

    _listener.configure(cfg);

    _sessionFactory = getConfiguration().buildSessionFactory();
    _session = _sessionFactory.openSession();
    _session.setFlushMode(FlushMode.COMMIT);
    _transaction = _session.beginTransaction();

    _listener.install(getSession(), cfg);

    _generator = GeneratorMap.get(_session);

    _alive = true;
}

From source file:com.ferrishibernatesupport.saveferris.dao.impl.DefaultRepository.java

License:Open Source License

@Override
public Session getSession() {
    Session currentSession = this.sessionFactory.getCurrentSession();
    currentSession.setFlushMode(FlushMode.COMMIT);
    return currentSession;
}

From source file:com.fiveamsolutions.nci.commons.util.HibernateHelper.java

License:Open Source License

/**
 * Open a hibernate session and bind it as the current session via
 * {@link ManagedSessionContext#bind(org.hibernate.classic.Session)}. The hibernate property
 * "hibernate.current_session_context_class" must be set to "managed" for this to have effect This method should be
 * called from within an Interceptor or Filter type class that is setting up the scope of the Session. This method
 * should then call {@link HibernateUtil#unbindAndCleanupSession()} when the scope of the Session is expired.
 *
 * @see ManagedSessionContext#bind(org.hibernate.classic.Session)
 * @param sf the session factory./*from  ww w  .  j a v a2s. c o m*/
 */
public void openAndBindSession(SessionFactory sf) {
    SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sf;
    org.hibernate.classic.Session currentSession = sessionFactoryImplementor.openSession(null, true, false,
            ConnectionReleaseMode.AFTER_STATEMENT);
    currentSession.setFlushMode(FlushMode.COMMIT);
    ManagedSessionContext.bind(currentSession);
}

From source file:com.gisgraphy.domain.geoloc.importer.GeonamesAdm1Importer.java

License:Open Source License

@Override
protected void setCommitFlushMode() {
    this.admDao.setFlushMode(FlushMode.COMMIT);

}

From source file:com.gisgraphy.domain.geoloc.importer.GeonamesAdm2Importer.java

License:Open Source License

@Override
protected void setCommitFlushMode() {
    this.admDao.setFlushMode(FlushMode.COMMIT);
}

From source file:com.gisgraphy.domain.geoloc.importer.GeonamesAlternateNamesImporter.java

License:Open Source License

@Override
protected void setCommitFlushMode() {
    this.gisFeatureDao.setFlushMode(FlushMode.COMMIT);
    this.cityDao.setFlushMode(FlushMode.COMMIT);
    this.alternateNameDao.setFlushMode(FlushMode.COMMIT);
}