final EventSource source = event.getSession(); final Iterable<FlushEntityEventListener> flushListeners = source.getFactory().getServiceRegistry() .getService( EventListenerRegistry.class )
private void doFlush() { checkTransactionNeeded(); checkTransactionSynchStatus(); try { if ( persistenceContext.getCascadeLevel() > 0 ) { throw new HibernateException( "Flush during cascade is dangerous" ); } FlushEvent flushEvent = new FlushEvent( this ); for ( FlushEventListener listener : listeners( EventType.FLUSH ) ) { listener.onFlush( flushEvent ); } delayedAfterCompletion(); } catch ( RuntimeException e ) { throw exceptionConverter.convert( e ); } }
final EventSource source = event.getSession(); final PersistenceContext persistenceContext = source.getPersistenceContext(); event.getNumberOfEntitiesProcessed(), event.getNumberOfCollectionsProcessed() );
EventSource session = event.getSession(); int collectionCount = flushCollections( session, persistenceContext ); event.setNumberOfEntitiesProcessed( entityCount ); event.setNumberOfCollectionsProcessed( collectionCount );
EventSource session = event.getSession(); int collectionCount = flushCollections( session, persistenceContext ); event.setNumberOfEntitiesProcessed( entityCount ); event.setNumberOfCollectionsProcessed( collectionCount );
@SuppressWarnings( value = {"unchecked"} ) private void logFlushResults(FlushEvent event) { if ( !LOG.isDebugEnabled() ) { return; } final EventSource session = event.getSession(); final PersistenceContext persistenceContext = session.getPersistenceContext(); LOG.debugf( "Flushed: %s insertions, %s updates, %s deletions to %s objects", session.getActionQueue().numberOfInsertions(), session.getActionQueue().numberOfUpdates(), session.getActionQueue().numberOfDeletions(), persistenceContext.getNumberOfManagedEntities() ); LOG.debugf( "Flushed: %s (re)creations, %s updates, %s removals to %s collections", session.getActionQueue().numberOfCollectionCreations(), session.getActionQueue().numberOfCollectionUpdates(), session.getActionQueue().numberOfCollectionRemovals(), persistenceContext.getCollectionEntries().size() ); new EntityPrinter( session.getFactory() ).toString( persistenceContext.getEntitiesByKey().entrySet() ); }
final EventSource source = event.getSession(); final PersistenceContext persistenceContext = source.getPersistenceContext(); event.getNumberOfEntitiesProcessed(), event.getNumberOfCollectionsProcessed() );
public void flush() throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); if ( persistenceContext.getCascadeLevel() > 0 ) { throw new HibernateException("Flush during cascade is dangerous"); } FlushEvent flushEvent = new FlushEvent( this ); for ( FlushEventListener listener : listeners( EventType.FLUSH ) ) { listener.onFlush( flushEvent ); } }
/** * Make sure the indexes are updated right after the hibernate flush, * avoiding object loading during a flush. Not needed during transactions. */ @Override public void onFlush(FlushEvent event) { if ( !eventProcessingEnabled ) { return; } Session session = event.getSession(); // TODO handle the "simulated" transaction when a Flush listener is registered // Synchronization synchronization = flushSynch.get( session ); // if ( synchronization != null ) { // //first cleanup // flushSynch.remove( session ); // log.debug( "flush event causing index update out of transaction" ); // synchronization.beforeCompletion(); // synchronization.afterCompletion( Status.STATUS_COMMITTED ); // } }
public void flush() throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); if ( persistenceContext.getCascadeLevel() > 0 ) { throw new HibernateException("Flush during cascade is dangerous"); } FlushEvent flushEvent = new FlushEvent( this ); for ( FlushEventListener listener : listeners( EventType.FLUSH ) ) { listener.onFlush( flushEvent ); } }
@Override public void onFlush(FlushEvent event) throws HibernateException { try { wrappedListener.onFlush(event); } catch (StaleObjectStateException e) { HibernateOptimisticLockException.rethrowOptimisticLockException(event.getSession(), e); } } }
private void doFlush() { checkTransactionNeeded(); checkTransactionSynchStatus(); try { if ( persistenceContext.getCascadeLevel() > 0 ) { throw new HibernateException( "Flush during cascade is dangerous" ); } FlushEvent flushEvent = new FlushEvent( this ); for ( FlushEventListener listener : listeners( EventType.FLUSH ) ) { listener.onFlush( flushEvent ); } delayedAfterCompletion(); } catch ( RuntimeException e ) { throw exceptionConverter.convert( e ); } }
@Override public void onFlush(FlushEvent event) throws HibernateException { stateManager.onEventBegin( event.getSession() ); try { delegate.onFlush( event ); } finally { stateManager.onEventFinished(); } }
/** * Force the session to flush, but don't throw an exception if performed outside of a transaction. * * @param session the Session object * @throws org.hibernate.HibernateException Indicates problems flushing the session or talking to the database */ public static void flushAllowNoTransaction(final Session session) throws HibernateException { SessionImplementor sessionImplementor = (SessionImplementor) session; errorIfClosed(sessionImplementor); try { if (sessionImplementor.getPersistenceContext().getCascadeLevel() > 0) { throw new HibernateException("Flush during cascade is dangerous"); } FlushEvent flushEvent = new FlushEvent((EventSource) sessionImplementor); for (final FlushEventListener listener : eventListenerGroup(session, EventType.FLUSH).listeners()) { listener.onFlush(flushEvent); } } catch (RuntimeException e) { throw sessionImplementor.getExceptionConverter().convert(e); } }
/** * Make sure the indexes are updated right after the hibernate flush, * avoiding object loading during a flush. Not needed during transactions. */ @Override public void onFlush(FlushEvent event) { if ( state.eventsDisabled() ) { return; } Session session = event.getSession(); Synchronization synchronization = flushSynch.get( session ); if ( synchronization != null ) { //first cleanup flushSynch.remove( session ); log.debug( "flush event causing index update out of transaction" ); synchronization.beforeCompletion(); synchronization.afterCompletion( Status.STATUS_COMMITTED ); } }
/** Handle the given flush event. * * @param event The flush event to be handled. * @throws HibernateException */ public void onFlush(FlushEvent event) throws HibernateException { final EventSource source = event.getSession(); final PersistenceContext persistenceContext = source.getPersistenceContext(); if ( persistenceContext.getEntityEntries().size() > 0 || persistenceContext.getCollectionEntries().size() > 0 ) { flushEverythingToExecutions(event); performExecutions(source); postFlush(source); if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().flush(); } } } }
/** Handle the given flush event. * * @param event The flush event to be handled. * @throws HibernateException */ public void onFlush(FlushEvent event) throws HibernateException { final EventSource source = event.getSession(); final PersistenceContext persistenceContext = source.getPersistenceContext(); if ( persistenceContext.getEntityEntries().size() > 0 || persistenceContext.getCollectionEntries().size() > 0 ) { flushEverythingToExecutions(event); performExecutions(source); postFlush(source); if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().flush(); } } } }
final EventSource source = event.getSession(); final Iterable<FlushEntityEventListener> flushListeners = source.getFactory().getServiceRegistry() .getService( EventListenerRegistry.class )
final EventSource source = event.getSession(); final Iterable<FlushEntityEventListener> flushListeners = source .getFactory()
final EventSource source = event.getSession(); final Iterable<FlushEntityEventListener> flushListeners = source .getFactory()