HHH-10201 - Fix element-collection attributes to always be audited if parent is audited.
This commit is contained in:
parent
42fe168056
commit
10148324d1
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue