use of org.hibernate.reactive.event.impl.DefaultReactiveInitializeCollectionEventListener 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());
}
}
use of org.hibernate.reactive.event.impl.DefaultReactiveInitializeCollectionEventListener in project hibernate-reactive by hibernate.
the class ReactiveSessionImpl method reactiveInitializeCollection.
@Override
public CompletionStage<Void> reactiveInitializeCollection(PersistentCollection collection, boolean writing) {
checkOpenOrWaitingForAutoClose();
pulseTransactionCoordinator();
InitializeCollectionEvent event = new InitializeCollectionEvent(collection, this);
return fastSessionServices.eventListenerGroup_INIT_COLLECTION.fireEventOnEachListener(event, (DefaultReactiveInitializeCollectionEventListener l) -> l::onReactiveInitializeCollection).handle((v, e) -> {
delayedAfterCompletion();
if (e instanceof MappingException) {
throw getExceptionConverter().convert(new IllegalArgumentException(e.getMessage()));
} else if (e instanceof RuntimeException) {
throw getExceptionConverter().convert((RuntimeException) e);
}
return returnNullorRethrow(e);
});
}
Aggregations