HHH-6064: only registering the Envers listeners if there are any audited entities
This commit is contained in:
parent
3e22ef111c
commit
1a1432179f
|
@ -96,6 +96,10 @@ public class EntitiesConfigurations {
|
||||||
return get(entityName) != null;
|
return get(entityName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasAuditedEntities() {
|
||||||
|
return entitiesConfigurations.size() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public RelationDescription getRelationDescription(String entityName, String propertyName) {
|
public RelationDescription getRelationDescription(String entityName, String propertyName) {
|
||||||
EntityConfiguration entCfg = entitiesConfigurations.get(entityName);
|
EntityConfiguration entCfg = entitiesConfigurations.get(entityName);
|
||||||
RelationDescription relDesc = entCfg.getRelationDescription(propertyName);
|
RelationDescription relDesc = entCfg.getRelationDescription(propertyName);
|
||||||
|
|
|
@ -60,14 +60,14 @@ public class EnversIntegrator implements Integrator {
|
||||||
listenerRegistry.addDuplicationStrategy( EnversListenerDuplicationStrategy.INSTANCE );
|
listenerRegistry.addDuplicationStrategy( EnversListenerDuplicationStrategy.INSTANCE );
|
||||||
|
|
||||||
final AuditConfiguration enversConfiguration = AuditConfiguration.getFor( configuration );
|
final AuditConfiguration enversConfiguration = AuditConfiguration.getFor( configuration );
|
||||||
// ref HHH-6064
|
|
||||||
// todo : if the returned AuditConfiguration says that no things are audited, we should just skip the listener registration
|
|
||||||
|
|
||||||
listenerRegistry.appendListeners( EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl( enversConfiguration ) );
|
if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
|
||||||
listenerRegistry.appendListeners( EventType.POST_INSERT, new EnversPostInsertEventListenerImpl( enversConfiguration ) );
|
listenerRegistry.appendListeners( EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl( enversConfiguration ) );
|
||||||
listenerRegistry.appendListeners( EventType.POST_UPDATE, new EnversPostUpdateEventListenerImpl( enversConfiguration ) );
|
listenerRegistry.appendListeners( EventType.POST_INSERT, new EnversPostInsertEventListenerImpl( enversConfiguration ) );
|
||||||
listenerRegistry.appendListeners( EventType.POST_COLLECTION_RECREATE, new EnversPostCollectionRecreateEventListenerImpl( enversConfiguration ) );
|
listenerRegistry.appendListeners( EventType.POST_UPDATE, new EnversPostUpdateEventListenerImpl( enversConfiguration ) );
|
||||||
listenerRegistry.appendListeners( EventType.PRE_COLLECTION_REMOVE, new EnversPreCollectionRemoveEventListenerImpl( enversConfiguration ) );
|
listenerRegistry.appendListeners( EventType.POST_COLLECTION_RECREATE, new EnversPostCollectionRecreateEventListenerImpl( enversConfiguration ) );
|
||||||
listenerRegistry.appendListeners( EventType.PRE_COLLECTION_UPDATE, new EnversPreCollectionUpdateEventListenerImpl( enversConfiguration ) );
|
listenerRegistry.appendListeners( EventType.PRE_COLLECTION_REMOVE, new EnversPreCollectionRemoveEventListenerImpl( enversConfiguration ) );
|
||||||
|
listenerRegistry.appendListeners( EventType.PRE_COLLECTION_UPDATE, new EnversPreCollectionUpdateEventListenerImpl( enversConfiguration ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue