public int execute(QueryParameters parameters, SharedSessionContractImplementor session) throws HibernateException { BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, updateHandler.getTargetedQueryable() ); if ( session.isEventSource() ) { ( (EventSource) session ).getActionQueue().addAction( action ); } else { action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session ); } return updateHandler.execute( session, parameters ); } }
protected void coordinateSharedCacheCleanup(SharedSessionContractImplementor session) { final BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, getCustomQuery().getQuerySpaces() ); if ( session.isEventSource() ) { ( (EventSource) session ).getActionQueue().addAction( action ); } else { action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session ); } }
@Override public int execute(QueryParameters parameters, SharedSessionContractImplementor session) throws HibernateException { BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, deleteHandler.getTargetedQueryable() ); if ( session.isEventSource() ) { ( (EventSource) session ).getActionQueue().addAction( action ); } else { action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session ); } return deleteHandler.execute( session, parameters ); } }
@Override public void finishUp(ResultSetProcessingContextImpl context, List<AfterLoadAction> afterLoadActionList) { final List<HydratedEntityRegistration> hydratedEntityRegistrations = context.getHydratedEntityRegistrationList(); // for arrays, we should end the collection load before resolving the entities, since the // actual array instances are not instantiated during loading finishLoadingArrays( context ); // IMPORTANT: reuse the same event instances for performance! final PreLoadEvent preLoadEvent; final PostLoadEvent postLoadEvent; if ( context.getSession().isEventSource() ) { preLoadEvent = new PreLoadEvent( (EventSource) context.getSession() ); postLoadEvent = new PostLoadEvent( (EventSource) context.getSession() ); } else { preLoadEvent = null; postLoadEvent = null; } // now finish loading the entities (2-phase load) performTwoPhaseLoad( preLoadEvent, context, hydratedEntityRegistrations ); // now we can finalize loading collections finishLoadingCollections( context ); // and trigger the afterInitialize() hooks afterInitialize( context, hydratedEntityRegistrations ); // finally, perform post-load operations postLoad( postLoadEvent, context, hydratedEntityRegistrations, afterLoadActionList ); }
protected int doExecute(QueryParameters parameters, SharedSessionContractImplementor session, String sql, List parameterSpecifications) throws HibernateException { BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, persister ); if ( session.isEventSource() ) { ( (EventSource) session ).getActionQueue().addAction( action );
if ( session.isEventSource() ) { pre = new PreLoadEvent( (EventSource) session ); post = new PostLoadEvent( (EventSource) session );
/** * PostLoad cannot occur during initializeEntity, as that call occurs *before* * the Set collections are added to the persistence context by Loader. * Without the split, LazyInitializationExceptions can occur in the Entity's * postLoad if it acts upon the collection. * * HHH-6043 * * @param entity The entity * @param session The Session * @param postLoadEvent The (re-used) post-load event */ public static void postLoad( final Object entity, final SharedSessionContractImplementor session, final PostLoadEvent postLoadEvent) { if ( session.isEventSource() ) { final PersistenceContext persistenceContext = session.getPersistenceContext(); final EntityEntry entityEntry = persistenceContext.getEntry( entity ); postLoadEvent.setEntity( entity ).setId( entityEntry.getId() ).setPersister( entityEntry.getPersister() ); final EventListenerGroup<PostLoadEventListener> listenerGroup = session.getFactory() .getServiceRegistry() .getService( EventListenerRegistry.class ) .getEventListenerGroup( EventType.POST_LOAD ); for ( PostLoadEventListener listener : listenerGroup.listeners() ) { listener.onPostLoad( postLoadEvent ); } } }
if ( session.isEventSource() ) { preLoadEvent.setEntity( entity ).setState( hydratedState ).setId( id ).setPersister( persister );
if ( session.isEventSource() ) { pre = new PreLoadEvent( (EventSource) session ); post = new PostLoadEvent( (EventSource) session );
private void preLoad(RowProcessingState rowProcessingState) { final SharedSessionContractImplementor session = rowProcessingState.getJdbcValuesSourceProcessingState().getSession(); final PreLoadEvent preLoadEvent = rowProcessingState.getJdbcValuesSourceProcessingState().getPreLoadEvent(); preLoadEvent.reset(); // Must occur after resolving identifiers! if ( session.isEventSource() ) { preLoadEvent.setEntity( entityInstance ) .setId( entityKey.getIdentifier() ) .setDescriptor( entityDescriptor ); final EventListenerGroup<PreLoadEventListener> listenerGroup = session.getFactory() .getServiceRegistry() .getService( EventListenerRegistry.class ) .getEventListenerGroup( EventType.PRE_LOAD ); for ( PreLoadEventListener listener : listenerGroup.listeners() ) { listener.onPreLoad( preLoadEvent ); } } }
/** * PostLoad cannot occur during initializeEntity, as that call occurs *before* * the Set collections are added to the persistence context by Loader. * Without the split, LazyInitializationExceptions can occur in the Entity's * postLoad if it acts upon the collection. * * HHH-6043 * * @param entity The entity * @param session The Session * @param postLoadEvent The (re-used) post-load event */ public static void postLoad( final Object entity, final SharedSessionContractImplementor session, final PostLoadEvent postLoadEvent) { if ( session.isEventSource() ) { final PersistenceContext persistenceContext = session.getPersistenceContext(); final EntityEntry entityEntry = persistenceContext.getEntry( entity ); postLoadEvent.setEntity( entity ).setId( entityEntry.getId() ).setDescriptor( entityEntry.getDescriptor() ); final EventListenerGroup<PostLoadEventListener> listenerGroup = session.getFactory() .getServiceRegistry() .getService( EventListenerRegistry.class ) .getEventListenerGroup( EventType.POST_LOAD ); for ( PostLoadEventListener listener : listenerGroup.listeners() ) { listener.onPostLoad( postLoadEvent ); } } }