final EventSource source = event.getSession(); try { source.getEventListenerManager().partialFlushStart(); event.setFlushRequired( flushIsReallyNeeded( event, source ) ); event.getNumberOfEntitiesProcessed(), event.getNumberOfEntitiesProcessed() );
/** * detect in-memory changes, determine if the changes are to tables * named in the query and, if so, complete execution the flush */ protected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException { checkOpen(); if ( !isTransactionInProgress() ) { // do not auto-flush while outside a transaction return false; } AutoFlushEvent event = new AutoFlushEvent( querySpaces, this ); for ( AutoFlushEventListener listener : listeners( EventType.AUTO_FLUSH ) ) { listener.onAutoFlush( event ); } return event.isFlushRequired(); }
private boolean flushIsReallyNeeded(AutoFlushEvent event, final EventSource source) { return source.getHibernateFlushMode() == FlushMode.ALWAYS || source.getActionQueue().areTablesToBeUpdated( event.getQuerySpaces() ); }
/** * Handle the given auto-flush event. * * @param event * The auto-flush event to be handled. * @throws HibernateException */ public void onAutoFlush(AutoFlushEvent event) throws HibernateException { final EventSource source = event.getSession(); if ( flushMightBeNeeded(source) ) { flushEverythingToExecutions(event); if ( flushIsReallyNeeded(event, source) ) { LOG.trace( "Need to execute flush" ); performExecutions(source); postFlush(source); // note: performExecutions() clears all collectionXxxxtion // collections (the collection actions) in the session if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().flush(); } } else { LOG.trace( "Don't need to execute flush" ); final int oldSize = source.getActionQueue().numberOfCollectionRemovals(); source.getActionQueue().clearFromFlushNeededCheck( oldSize ); } event.setFlushRequired( flushIsReallyNeeded( event, source ) ); } }
@Override public void onAutoFlush(AutoFlushEvent event) throws HibernateException { try { wrappedListener.onAutoFlush(event); } catch (StaleObjectStateException e) { HibernateOptimisticLockException.rethrowOptimisticLockException(event.getSession(), e); } } }
public void autoFlush(Set<String> querySpaces, SessionImplementor sessionImplementor) { AutoFlushEvent event = new AutoFlushEvent(querySpaces, (EventSource) sessionImplementor); for (AutoFlushEventListener listener : sessionImplementor.getFactory().getServiceRegistry().getService(EventListenerRegistry.class).getEventListenerGroup(EventType.AUTO_FLUSH).listeners()) { listener.onAutoFlush(event); } }
/** * Handle the given auto-flush event. * * @param event * The auto-flush event to be handled. * @throws HibernateException */ public void onAutoFlush(AutoFlushEvent event) throws HibernateException { final EventSource source = event.getSession(); if ( flushMightBeNeeded(source) ) { flushEverythingToExecutions(event); if ( flushIsReallyNeeded(event, source) ) { LOG.trace( "Need to execute flush" ); performExecutions(source); postFlush(source); // note: performExecutions() clears all collectionXxxxtion // collections (the collection actions) in the session if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().flush(); } } else { LOG.trace( "Don't need to execute flush" ); final int oldSize = source.getActionQueue().numberOfCollectionRemovals(); source.getActionQueue().clearFromFlushNeededCheck( oldSize ); } event.setFlushRequired( flushIsReallyNeeded( event, source ) ); } }
@Override public void onAutoFlush(AutoFlushEvent event) throws HibernateException { stateManager.onEventBegin( event.getSession() ); try { delegate.onAutoFlush( event ); } finally { stateManager.onEventFinished(); } }
/** * detect in-memory changes, determine if the changes are to tables * named in the query and, if so, complete execution the flush */ protected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException { errorIfClosed(); if ( ! isTransactionInProgress() ) { // do not auto-flush while outside a transaction return false; } AutoFlushEvent event = new AutoFlushEvent( querySpaces, this ); for ( AutoFlushEventListener listener : listeners( EventType.AUTO_FLUSH ) ) { listener.onAutoFlush( event ); } return event.isFlushRequired(); }
final EventSource source = event.getSession(); try { source.getEventListenerManager().partialFlushStart(); event.setFlushRequired( flushIsReallyNeeded( event, source ) ); event.getNumberOfEntitiesProcessed(), event.getNumberOfEntitiesProcessed() );
private boolean flushIsReallyNeeded(AutoFlushEvent event, final EventSource source) { return source.getActionQueue() .areTablesToBeUpdated( event.getQuerySpaces() ) || source.getFlushMode()==FlushMode.ALWAYS; }
/** * detect in-memory changes, determine if the changes are to tables * named in the query and, if so, complete execution the flush */ protected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException { checkOpen(); if ( !isTransactionInProgress() ) { // do not auto-flush while outside a transaction return false; } AutoFlushEvent event = new AutoFlushEvent( querySpaces, this ); for ( AutoFlushEventListener listener : listeners( EventType.AUTO_FLUSH ) ) { listener.onAutoFlush( event ); } return event.isFlushRequired(); }
private boolean flushIsReallyNeeded(AutoFlushEvent event, final EventSource source) { return source.getActionQueue() .areTablesToBeUpdated( event.getQuerySpaces() ) || source.getFlushMode()==FlushMode.ALWAYS; }
/** * detect in-memory changes, determine if the changes are to tables * named in the query and, if so, complete execution the flush */ protected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException { errorIfClosed(); if ( ! isTransactionInProgress() ) { // do not auto-flush while outside a transaction return false; } AutoFlushEvent event = new AutoFlushEvent( querySpaces, this ); for ( AutoFlushEventListener listener : listeners( EventType.AUTO_FLUSH ) ) { listener.onAutoFlush( event ); } return event.isFlushRequired(); }
private boolean flushIsReallyNeeded(AutoFlushEvent event, final EventSource source) { return source.getHibernateFlushMode() == FlushMode.ALWAYS || source.getActionQueue().areTablesToBeUpdated( event.getQuerySpaces() ); }