Search in sources :

Example 1 with DefaultReactiveAutoFlushEventListener

use of org.hibernate.reactive.event.impl.DefaultReactiveAutoFlushEventListener in project hibernate-reactive by hibernate.

the class ReactiveIntegrator method attachEventContextManagingListenersIfRequired.

private void attachEventContextManagingListenersIfRequired(SessionFactoryServiceRegistry serviceRegistry) {
    if (ReactiveModeCheck.isReactiveRegistry(serviceRegistry)) {
        LOG.startHibernateReactive();
        EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
        eventListenerRegistry.addDuplicationStrategy(ReplacementDuplicationStrategy.INSTANCE);
        eventListenerRegistry.getEventListenerGroup(EventType.AUTO_FLUSH).appendListener(new DefaultReactiveAutoFlushEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.FLUSH).appendListener(new DefaultReactiveFlushEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.FLUSH_ENTITY).appendListener(new DefaultReactiveFlushEntityEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.PERSIST).appendListener(new DefaultReactivePersistEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.PERSIST_ONFLUSH).appendListener(new DefaultReactivePersistOnFlushEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.MERGE).appendListener(new DefaultReactiveMergeEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.DELETE).appendListener(new DefaultReactiveDeleteEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.REFRESH).appendListener(new DefaultReactiveRefreshEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.LOCK).appendListener(new DefaultReactiveLockEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.LOAD).appendListener(new DefaultReactiveLoadEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.INIT_COLLECTION).appendListener(new DefaultReactiveInitializeCollectionEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.POST_LOAD).appendListener(new DefaultReactivePostLoadEventListener());
        eventListenerRegistry.getEventListenerGroup(EventType.RESOLVE_NATURAL_ID).appendListener(new DefaultReactiveResolveNaturalIdEventListener());
    }
}
Also used : DefaultReactiveAutoFlushEventListener(org.hibernate.reactive.event.impl.DefaultReactiveAutoFlushEventListener) DefaultReactiveFlushEventListener(org.hibernate.reactive.event.impl.DefaultReactiveFlushEventListener) DefaultReactiveRefreshEventListener(org.hibernate.reactive.event.impl.DefaultReactiveRefreshEventListener) DefaultReactivePersistEventListener(org.hibernate.reactive.event.impl.DefaultReactivePersistEventListener) DefaultReactiveInitializeCollectionEventListener(org.hibernate.reactive.event.impl.DefaultReactiveInitializeCollectionEventListener) DefaultReactivePersistOnFlushEventListener(org.hibernate.reactive.event.impl.DefaultReactivePersistOnFlushEventListener) DefaultReactiveDeleteEventListener(org.hibernate.reactive.event.impl.DefaultReactiveDeleteEventListener) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry) DefaultReactiveMergeEventListener(org.hibernate.reactive.event.impl.DefaultReactiveMergeEventListener) DefaultReactiveLockEventListener(org.hibernate.reactive.event.impl.DefaultReactiveLockEventListener) DefaultReactiveLoadEventListener(org.hibernate.reactive.event.impl.DefaultReactiveLoadEventListener) DefaultReactiveResolveNaturalIdEventListener(org.hibernate.reactive.event.impl.DefaultReactiveResolveNaturalIdEventListener) DefaultReactiveFlushEntityEventListener(org.hibernate.reactive.event.impl.DefaultReactiveFlushEntityEventListener) DefaultReactivePostLoadEventListener(org.hibernate.reactive.event.impl.DefaultReactivePostLoadEventListener)

Example 2 with DefaultReactiveAutoFlushEventListener

use of org.hibernate.reactive.event.impl.DefaultReactiveAutoFlushEventListener in project hibernate-reactive by hibernate.

the class ReactiveSessionImpl method reactiveAutoFlushIfRequired.

// TODO: parameterize the SessionFactory constructor by ReactiveNativeSQLQueryPlan::new
// @Override
// protected ReactiveNativeSQLQueryPlan getNativeQueryPlan(NativeSQLQuerySpecification spec) throws HibernateException {
// QueryPlanCache queryPlanCache = getFactory().getQueryPlanCache();
// return (ReactiveNativeSQLQueryPlan) queryPlanCache.getNativeSQLQueryPlan( spec );
// }
protected CompletionStage<Void> reactiveAutoFlushIfRequired(Set<?> querySpaces) throws HibernateException {
    checkOpen();
    // if ( !isTransactionInProgress() ) {
    // do not auto-flush while outside a transaction
    // return CompletionStages.nullFuture();
    // }
    AutoFlushEvent event = new AutoFlushEvent(querySpaces, this);
    return fastSessionServices.eventListenerGroup_AUTO_FLUSH.fireEventOnEachListener(event, (DefaultReactiveAutoFlushEventListener l) -> l::reactiveOnAutoFlush);
}
Also used : DefaultReactiveAutoFlushEventListener(org.hibernate.reactive.event.impl.DefaultReactiveAutoFlushEventListener) AutoFlushEvent(org.hibernate.event.spi.AutoFlushEvent) SessionImpl(org.hibernate.internal.SessionImpl) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl)

Aggregations

DefaultReactiveAutoFlushEventListener (org.hibernate.reactive.event.impl.DefaultReactiveAutoFlushEventListener)2 EventListenerRegistry (org.hibernate.event.service.spi.EventListenerRegistry)1 AutoFlushEvent (org.hibernate.event.spi.AutoFlushEvent)1 SessionFactoryImpl (org.hibernate.internal.SessionFactoryImpl)1 SessionImpl (org.hibernate.internal.SessionImpl)1 DefaultReactiveDeleteEventListener (org.hibernate.reactive.event.impl.DefaultReactiveDeleteEventListener)1 DefaultReactiveFlushEntityEventListener (org.hibernate.reactive.event.impl.DefaultReactiveFlushEntityEventListener)1 DefaultReactiveFlushEventListener (org.hibernate.reactive.event.impl.DefaultReactiveFlushEventListener)1 DefaultReactiveInitializeCollectionEventListener (org.hibernate.reactive.event.impl.DefaultReactiveInitializeCollectionEventListener)1 DefaultReactiveLoadEventListener (org.hibernate.reactive.event.impl.DefaultReactiveLoadEventListener)1 DefaultReactiveLockEventListener (org.hibernate.reactive.event.impl.DefaultReactiveLockEventListener)1 DefaultReactiveMergeEventListener (org.hibernate.reactive.event.impl.DefaultReactiveMergeEventListener)1 DefaultReactivePersistEventListener (org.hibernate.reactive.event.impl.DefaultReactivePersistEventListener)1 DefaultReactivePersistOnFlushEventListener (org.hibernate.reactive.event.impl.DefaultReactivePersistOnFlushEventListener)1 DefaultReactivePostLoadEventListener (org.hibernate.reactive.event.impl.DefaultReactivePostLoadEventListener)1 DefaultReactiveRefreshEventListener (org.hibernate.reactive.event.impl.DefaultReactiveRefreshEventListener)1 DefaultReactiveResolveNaturalIdEventListener (org.hibernate.reactive.event.impl.DefaultReactiveResolveNaturalIdEventListener)1