Search in sources :

Example 1 with InitializeCollectionEvent

use of org.hibernate.event.spi.InitializeCollectionEvent in project hibernate-orm by hibernate.

the class SessionImpl method initializeCollection.

@Override
public void initializeCollection(PersistentCollection<?> collection, boolean writing) {
    checkOpenOrWaitingForAutoClose();
    pulseTransactionCoordinator();
    InitializeCollectionEvent event = new InitializeCollectionEvent(collection, this);
    fastSessionServices.eventListenerGroup_INIT_COLLECTION.fireEventOnEachListener(event, InitializeCollectionEventListener::onInitializeCollection);
    delayedAfterCompletion();
}
Also used : InitializeCollectionEventListener(org.hibernate.event.spi.InitializeCollectionEventListener) InitializeCollectionEvent(org.hibernate.event.spi.InitializeCollectionEvent)

Example 2 with InitializeCollectionEvent

use of org.hibernate.event.spi.InitializeCollectionEvent 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);
    });
}
Also used : DefaultReactiveInitializeCollectionEventListener(org.hibernate.reactive.event.impl.DefaultReactiveInitializeCollectionEventListener) InitializeCollectionEvent(org.hibernate.event.spi.InitializeCollectionEvent) MappingException(org.hibernate.MappingException)

Example 3 with InitializeCollectionEvent

use of org.hibernate.event.spi.InitializeCollectionEvent in project hibernate-orm by hibernate.

the class SessionImpl method initializeCollection.

@Override
public void initializeCollection(PersistentCollection collection, boolean writing) {
    checkOpenOrWaitingForAutoClose();
    checkTransactionSynchStatus();
    InitializeCollectionEvent event = new InitializeCollectionEvent(collection, this);
    for (InitializeCollectionEventListener listener : listeners(EventType.INIT_COLLECTION)) {
        listener.onInitializeCollection(event);
    }
    delayedAfterCompletion();
}
Also used : InitializeCollectionEventListener(org.hibernate.event.spi.InitializeCollectionEventListener) InitializeCollectionEvent(org.hibernate.event.spi.InitializeCollectionEvent)

Aggregations

InitializeCollectionEvent (org.hibernate.event.spi.InitializeCollectionEvent)3 InitializeCollectionEventListener (org.hibernate.event.spi.InitializeCollectionEventListener)2 MappingException (org.hibernate.MappingException)1 DefaultReactiveInitializeCollectionEventListener (org.hibernate.reactive.event.impl.DefaultReactiveInitializeCollectionEventListener)1