Skip to content

Commit a8678bb

Browse files
mbelladeyrodiere
authored andcommitted
HHH-19523 Disable pre/post collection events in StatelessSession
1 parent eae088a commit a8678bb

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@
4141
import org.hibernate.event.monitor.spi.EventMonitor;
4242
import org.hibernate.event.monitor.spi.DiagnosticEvent;
4343
import org.hibernate.event.service.spi.EventListenerGroups;
44-
import org.hibernate.event.spi.PostCollectionRecreateEvent;
45-
import org.hibernate.event.spi.PostCollectionRecreateEventListener;
46-
import org.hibernate.event.spi.PostCollectionRemoveEvent;
47-
import org.hibernate.event.spi.PostCollectionRemoveEventListener;
48-
import org.hibernate.event.spi.PostCollectionUpdateEvent;
49-
import org.hibernate.event.spi.PostCollectionUpdateEventListener;
5044
import org.hibernate.event.spi.PostDeleteEvent;
5145
import org.hibernate.event.spi.PostDeleteEventListener;
5246
import org.hibernate.event.spi.PostInsertEvent;
@@ -55,12 +49,6 @@
5549
import org.hibernate.event.spi.PostUpdateEventListener;
5650
import org.hibernate.event.spi.PostUpsertEvent;
5751
import org.hibernate.event.spi.PostUpsertEventListener;
58-
import org.hibernate.event.spi.PreCollectionRecreateEvent;
59-
import org.hibernate.event.spi.PreCollectionRecreateEventListener;
60-
import org.hibernate.event.spi.PreCollectionRemoveEvent;
61-
import org.hibernate.event.spi.PreCollectionRemoveEventListener;
62-
import org.hibernate.event.spi.PreCollectionUpdateEvent;
63-
import org.hibernate.event.spi.PreCollectionUpdateEventListener;
6452
import org.hibernate.event.spi.PreDeleteEvent;
6553
import org.hibernate.event.spi.PreDeleteEventListener;
6654
import org.hibernate.event.spi.PreInsertEvent;
@@ -634,46 +622,49 @@ protected void firePostDelete(Object entity, Object id, EntityPersister persiste
634622
PostDeleteEventListener::onPostDelete );
635623
}
636624

625+
// Note: the pre/post collection events have been disabled for stateless sessions
626+
// as they were not actually useful (see https://hibernate.atlassian.net/browse/HHH-19523)
627+
637628
// Hibernate Reactive may need to call this
638629
protected void firePreRecreate(PersistentCollection<?> collection, CollectionPersister persister) {
639-
eventListenerGroups.eventListenerGroup_PRE_COLLECTION_RECREATE.fireLazyEventOnEachListener(
640-
() -> new PreCollectionRecreateEvent( persister, collection, null ),
641-
PreCollectionRecreateEventListener::onPreRecreateCollection );
630+
// eventListenerGroups.eventListenerGroup_PRE_COLLECTION_RECREATE.fireLazyEventOnEachListener(
631+
// () -> new PreCollectionRecreateEvent( persister, collection, null ),
632+
// PreCollectionRecreateEventListener::onPreRecreateCollection );
642633
}
643634

644635
// Hibernate Reactive may need to call this
645636
protected void firePreUpdate(PersistentCollection<?> collection, CollectionPersister persister) {
646-
eventListenerGroups.eventListenerGroup_PRE_COLLECTION_UPDATE.fireLazyEventOnEachListener(
647-
() -> new PreCollectionUpdateEvent( persister, collection, null ),
648-
PreCollectionUpdateEventListener::onPreUpdateCollection );
637+
// eventListenerGroups.eventListenerGroup_PRE_COLLECTION_UPDATE.fireLazyEventOnEachListener(
638+
// () -> new PreCollectionUpdateEvent( persister, collection, null ),
639+
// PreCollectionUpdateEventListener::onPreUpdateCollection );
649640
}
650641

651642
// Hibernate Reactive may need to call this
652643
protected void firePreRemove(PersistentCollection<?> collection, Object owner, CollectionPersister persister) {
653-
eventListenerGroups.eventListenerGroup_PRE_COLLECTION_REMOVE.fireLazyEventOnEachListener(
654-
() -> new PreCollectionRemoveEvent( persister, collection, null, owner ),
655-
PreCollectionRemoveEventListener::onPreRemoveCollection );
644+
// eventListenerGroups.eventListenerGroup_PRE_COLLECTION_REMOVE.fireLazyEventOnEachListener(
645+
// () -> new PreCollectionRemoveEvent( persister, collection, null, owner ),
646+
// PreCollectionRemoveEventListener::onPreRemoveCollection );
656647
}
657648

658649
// Hibernate Reactive may need to call this
659650
protected void firePostRecreate(PersistentCollection<?> collection, CollectionPersister persister) {
660-
eventListenerGroups.eventListenerGroup_POST_COLLECTION_RECREATE.fireLazyEventOnEachListener(
661-
() -> new PostCollectionRecreateEvent( persister, collection, null ),
662-
PostCollectionRecreateEventListener::onPostRecreateCollection );
651+
// eventListenerGroups.eventListenerGroup_POST_COLLECTION_RECREATE.fireLazyEventOnEachListener(
652+
// () -> new PostCollectionRecreateEvent( persister, collection, null ),
653+
// PostCollectionRecreateEventListener::onPostRecreateCollection );
663654
}
664655

665656
// Hibernate Reactive may need to call this
666657
protected void firePostUpdate(PersistentCollection<?> collection, CollectionPersister persister) {
667-
eventListenerGroups.eventListenerGroup_POST_COLLECTION_UPDATE.fireLazyEventOnEachListener(
668-
() -> new PostCollectionUpdateEvent( persister, collection, null ),
669-
PostCollectionUpdateEventListener::onPostUpdateCollection );
658+
// eventListenerGroups.eventListenerGroup_POST_COLLECTION_UPDATE.fireLazyEventOnEachListener(
659+
// () -> new PostCollectionUpdateEvent( persister, collection, null ),
660+
// PostCollectionUpdateEventListener::onPostUpdateCollection );
670661
}
671662

672663
// Hibernate Reactive may need to call this
673664
protected void firePostRemove(PersistentCollection<?> collection, Object owner, CollectionPersister persister) {
674-
eventListenerGroups.eventListenerGroup_POST_COLLECTION_REMOVE.fireLazyEventOnEachListener(
675-
() -> new PostCollectionRemoveEvent( persister, collection, null, owner ),
676-
PostCollectionRemoveEventListener::onPostRemoveCollection );
665+
// eventListenerGroups.eventListenerGroup_POST_COLLECTION_REMOVE.fireLazyEventOnEachListener(
666+
// () -> new PostCollectionRemoveEvent( persister, collection, null, owner ),
667+
// PostCollectionRemoveEventListener::onPostRemoveCollection );
677668
}
678669

679670
// collections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)