[hibernate-dev] HHH-6942 - Envers Collection revision entries don't include deletes on detached entity saveOrUpdate

Łukasz Antoniak lukasz.antoniak at gmail.com
Sat Jan 28 05:44:08 EST 2012


Yes, https://hibernate.onjira.com/browse/HHH-3088 describes the behavior.

 From the perspective of hibernate-core module this cannot be easily resolved. Fetching related objects would influence performance. But from Envers point of view, we might actually execute a query 
and produce a warning message, don't you think?

Just to clarify:

What I intended to do was to experiment with EnversPreCollectionRemoveEventListenerImpl.onPreRemoveCollection() method:
CollectionEntry collectionEntry = getCollectionEntry( event );
if (collectionEntry == null) {
     // Load collection and try to obtain collection entry once again...
}
I'm not sure if this resolves HHH-6942, but I wanted to give it a try.
I have initialized a collection by executing: event.getSession().getFactory().getCollectionPersister("[ROLE]").initialize(event.getAffectedOwnerIdOrNull(), event.getSession());
Of course I had to hardcode the role parameter, but it was just a proof of concept. Unfortunately produced collection entry has empty loadedPersister attribute so the code crashes while executing 
BaseEnversCollectionEventListener.onCollectionAction() method. That is why I've asked how to manually initialize collection inside PreCollectionRemoveEventListener.onPreRemoveCollection() implementation.

Regards,
Lukasz



More information about the hibernate-dev mailing list