HHH-10201 - Fix element-collection attributes to always be audited if parent is audited.

This commit is contained in:
Chris Cranford 2018-09-04 14:07:10 -04:00
parent 42fe168056
commit 10148324d1
1 changed files with 12 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import org.hibernate.envers.internal.synchronization.work.FakeBidirectionalRelat
import org.hibernate.envers.internal.synchronization.work.PersistentCollectionChangeWorkUnit;
import org.hibernate.event.spi.AbstractCollectionEvent;
import org.hibernate.persister.collection.AbstractCollectionPersister;
import org.hibernate.persister.collection.OneToManyPersister;
/**
* Base class for Envers' collection event related listeners
@ -146,8 +147,17 @@ public abstract class BaseEnversCollectionEventListener extends BaseEnversEventL
*/
protected boolean shouldGenerateRevision(AbstractCollectionEvent event) {
final String entityName = event.getAffectedOwnerEntityName();
return getEnversService().getGlobalConfiguration().isGenerateRevisionsForCollections()
&& getEnversService().getEntitiesConfigurations().isVersioned( entityName );
if ( getEnversService().getEntitiesConfigurations().isVersioned( entityName ) ) {
final CollectionEntry collectionEntry = getCollectionEntry( event );
final boolean isInverse = collectionEntry.getLoadedPersister().isInverse();
final boolean isOneToMany = collectionEntry.getLoadedPersister() instanceof OneToManyPersister;
if ( isInverse || isOneToMany ) {
return getEnversService().getGlobalConfiguration().isGenerateRevisionsForCollections();
}
return true;
}
// if the entity is not audited, we dont generate a revision.
return false;
}
/**