List of usage examples for org.hibernate.engine.spi SessionImplementor flush
void flush() throws HibernateException;
From source file:com.googlecode.hibernate.audit.synchronization.AuditProcess.java
License:Open Source License
public void doBeforeTransactionCompletion(SessionImplementor session) { if (workUnits.size() == 0) { return;/*from ww w . j av a 2s. c o m*/ } if (!session.getTransactionCoordinator().isActive()) { log.debug( "Skipping hibernate-audit transaction hook due to non-active (most likely marked as rollback) transaction"); return; } if (FlushMode.MANUAL == session.getHibernateFlushMode() || session.isClosed()) { Session temporarySession = null; try { temporarySession = session.sessionWithOptions().connection().autoClose(false) .connectionHandlingMode( PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION) .openSession(); executeInSession(temporarySession); temporarySession.flush(); } finally { if (temporarySession != null) { temporarySession.close(); } } } else { executeInSession(session); // explicitly flushing the session, as the auto-flush may have already happened. session.flush(); } }
From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.WrappedHibernateList.java
License:Open Source License
public int size() { if (cachedSize != -1) { return cachedSize; }/*from w ww . j a v a 2s. com*/ if (getDelegate() instanceof AbstractPersistentCollection) { final AbstractPersistentCollection collection = (AbstractPersistentCollection) getDelegate(); if (collection.wasInitialized()) { cachedSize = -1; return getDelegate().size(); } final SessionImplementor session = collection.getSession(); CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(collection); CollectionPersister persister = entry.getLoadedPersister(); if (collection.hasQueuedOperations()) { session.flush(); } cachedSize = persister.getSize(entry.getLoadedKey(), session); return cachedSize; } return getDelegate().size(); }