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);
}
Aggregations