Search in sources :

Example 1 with PostCommitInsertEventListener

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

the class EntityIdentityInsertAction method postCommitInsert.

private void postCommitInsert(boolean success) {
    final EventListenerGroup<PostInsertEventListener> listenerGroup = listenerGroup(EventType.POST_COMMIT_INSERT);
    if (listenerGroup.isEmpty()) {
        return;
    }
    final PostInsertEvent event = new PostInsertEvent(getInstance(), generatedId, getState(), getPersister(), eventSource());
    for (PostInsertEventListener listener : listenerGroup.listeners()) {
        if (PostCommitInsertEventListener.class.isInstance(listener)) {
            if (success) {
                listener.onPostInsert(event);
            } else {
                ((PostCommitInsertEventListener) listener).onPostInsertCommitFailed(event);
            }
        } else {
            //default to the legacy implementation that always fires the event
            listener.onPostInsert(event);
        }
    }
}
Also used : PostInsertEventListener(org.hibernate.event.spi.PostInsertEventListener) PostCommitInsertEventListener(org.hibernate.event.spi.PostCommitInsertEventListener) PostInsertEvent(org.hibernate.event.spi.PostInsertEvent)

Example 2 with PostCommitInsertEventListener

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

the class EntityInsertAction method postCommitInsert.

private void postCommitInsert(boolean success) {
    final EventListenerGroup<PostInsertEventListener> listenerGroup = listenerGroup(EventType.POST_COMMIT_INSERT);
    if (listenerGroup.isEmpty()) {
        return;
    }
    final PostInsertEvent event = new PostInsertEvent(getInstance(), getId(), getState(), getPersister(), eventSource());
    for (PostInsertEventListener listener : listenerGroup.listeners()) {
        if (PostCommitInsertEventListener.class.isInstance(listener)) {
            if (success) {
                listener.onPostInsert(event);
            } else {
                ((PostCommitInsertEventListener) listener).onPostInsertCommitFailed(event);
            }
        } else {
            //default to the legacy implementation that always fires the event
            listener.onPostInsert(event);
        }
    }
}
Also used : PostInsertEventListener(org.hibernate.event.spi.PostInsertEventListener) PostCommitInsertEventListener(org.hibernate.event.spi.PostCommitInsertEventListener) PostInsertEvent(org.hibernate.event.spi.PostInsertEvent)

Aggregations

PostCommitInsertEventListener (org.hibernate.event.spi.PostCommitInsertEventListener)2 PostInsertEvent (org.hibernate.event.spi.PostInsertEvent)2 PostInsertEventListener (org.hibernate.event.spi.PostInsertEventListener)2