Search in sources :

Example 1 with LazyIterator

use of org.hibernate.internal.util.collections.LazyIterator in project hibernate-orm by hibernate.

the class AbstractFlushingEventListener method flushEverythingToExecutions.

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Pre-flushing section
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
	 * Coordinates the processing necessary to get things ready for executions
	 * as db calls by preping the session caches and moving the appropriate
	 * entities and collections to their respective execution queues.
	 *
	 * @param event The flush event.
	 * @throws HibernateException Error flushing caches to execution queues.
	 */
protected void flushEverythingToExecutions(FlushEvent event) throws HibernateException {
    LOG.trace("Flushing session");
    EventSource session = event.getSession();
    final PersistenceContext persistenceContext = session.getPersistenceContext();
    session.getInterceptor().preFlush(new LazyIterator(persistenceContext.getEntitiesByKey()));
    prepareEntityFlushes(session, persistenceContext);
    // we could move this inside if we wanted to
    // tolerate collection initializations during
    // collection dirty checking:
    prepareCollectionFlushes(persistenceContext);
    // now, any collections that are initialized
    // inside this block do not get updated - they
    // are ignored until the next flush
    persistenceContext.setFlushing(true);
    try {
        int entityCount = flushEntities(event, persistenceContext);
        int collectionCount = flushCollections(session, persistenceContext);
        event.setNumberOfEntitiesProcessed(entityCount);
        event.setNumberOfCollectionsProcessed(collectionCount);
    } finally {
        persistenceContext.setFlushing(false);
    }
    //some statistics
    logFlushResults(event);
}
Also used : LazyIterator(org.hibernate.internal.util.collections.LazyIterator) EventSource(org.hibernate.event.spi.EventSource) PersistenceContext(org.hibernate.engine.spi.PersistenceContext) CascadePoint(org.hibernate.engine.internal.CascadePoint)

Aggregations

CascadePoint (org.hibernate.engine.internal.CascadePoint)1 PersistenceContext (org.hibernate.engine.spi.PersistenceContext)1 EventSource (org.hibernate.event.spi.EventSource)1 LazyIterator (org.hibernate.internal.util.collections.LazyIterator)1