org.hibernate.Interceptor.onCollectionRemove()

Here are the examples of the java api org.hibernate.Interceptor.onCollectionRemove() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

19 Source : InterceptorChain.java
with Apache License 2.0
from robinfriedli

@Override
public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
    if (!INTERCEPTORS_MUTED.get()) {
        first.onCollectionRemove(collection, key);
    } else {
        super.onCollectionRemove(collection, key);
    }
}

19 Source : ChainableInterceptor.java
with Apache License 2.0
from robinfriedli

@Override
public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
    try {
        onCollectionRemoveChained(collection, key);
    } catch (Throwable e) {
        logger.error("Error in onCollectionRemove of ChainableInterceptor " + getClreplaced().getSimpleName(), e);
    }
    next.onCollectionRemove(collection, key);
}

18 Source : ChainingInterceptor.java
with Apache License 2.0
from isstac

@Override
public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
    for (Interceptor i : interceptors) {
        i.onCollectionRemove(collection, key);
    }
}

13 Source : AbstractReactiveFlushingEventListener.java
with GNU Lesser General Public License v2.1
from hibernate

/**
 * process any unreferenced collections and then inspect all known collections,
 * scheduling creates/removes/updates
 */
private int flushCollections(final EventSource session, final PersistenceContext persistenceContext) throws HibernateException {
    LOG.trace("Processing unreferenced collections");
    final int count = persistenceContext.getCollectionEntriesSize();
    persistenceContext.forEachCollectionEntry((persistentCollection, collectionEntry) -> {
        if (!collectionEntry.isReached() && !collectionEntry.isIgnore()) {
            Collections.processUnreachableCollection(persistentCollection, session);
        }
    }, true);
    // Schedule updates to collections:
    LOG.trace("Scheduling collection removes/(re)creates/updates");
    final ReactiveActionQueue actionQueue = session.unwrap(ReactiveSession.clreplaced).getReactiveActionQueue();
    final Interceptor interceptor = session.getInterceptor();
    persistenceContext.forEachCollectionEntry((coll, ce) -> {
        if (ce.isDorecreate()) {
            interceptor.onCollectionRecreate(coll, ce.getCurrentKey());
            actionQueue.addAction(new ReactiveCollectionRecreateAction(coll, ce.getCurrentPersister(), ce.getCurrentKey(), session));
        }
        if (ce.isDoremove()) {
            interceptor.onCollectionRemove(coll, ce.getLoadedKey());
            actionQueue.addAction(new ReactiveCollectionRemoveAction(coll, ce.getLoadedPersister(), ce.getLoadedKey(), ce.isSnapshotEmpty(coll), session));
        }
        if (ce.isDoupdate()) {
            interceptor.onCollectionUpdate(coll, ce.getLoadedKey());
            actionQueue.addAction(new ReactiveCollectionUpdateAction(coll, ce.getLoadedPersister(), ce.getLoadedKey(), ce.isSnapshotEmpty(coll), session));
        }
        // todo : I'm not sure the !wasInitialized part should really be part of this check
        if (!coll.wasInitialized() && coll.hasQueuedOperations()) {
            actionQueue.addAction(new QueuedOperationCollectionAction(coll, ce.getLoadedPersister(), ce.getLoadedKey(), session));
        }
    }, true);
    actionQueue.sortCollectionActions();
    return count;
}