Class AuditChangeSet<E,C>

java.lang.Object
org.hibernate.audit.spi.AuditChangeSet<E,C>
Type Parameters:
E - the execution-specific entity audit handler carried with entity changes
C - the execution-specific collection audit handler carried with collection changes

public class AuditChangeSet<E,C> extends Object

Transaction-scoped audit change set with shared audit merge semantics.

This type deliberately knows nothing about how audit work is executed. It only records entity and collection audit changes and merges repeated entity changes for the same EntityKey. Legacy audit infrastructure may consume the resulting changes by invoking legacy writers directly, while the graph action queue may consume the same merged changes by materializing graph flush operations.

Entity changes are merged because there can only be one audit row for a given entity key in a transaction. Collection changes are keyed by collection role and owner id and are recorded once, preserving the first snapshot captured for the collection during the transaction.

Since:
8.0
  • Constructor Details

    • AuditChangeSet

      public AuditChangeSet()
  • Method Details

    • addEntityChange

      public void addEntityChange(EntityKey entityKey, Object entity, Object[] values, ModificationType modificationType, E entityAuditHandler)

      Add or merge an entity audit change.

      If this is the first change for entityKey, it is stored as-is. Otherwise, the existing and incoming modification types are collapsed using audit semantics: for example ADD followed by MOD remains ADD, MOD followed by DEL becomes DEL, and ADD followed by DEL removes the audit change.

    • addCollectionChange

      public void addCollectionChange(CollectionPersister collectionPersister, PersistentCollection<?> collection, Object ownerId, Object originalSnapshot, C collectionAuditHandler)

      Add a collection audit change if one has not already been captured.

      The first collection change wins because it carries the original snapshot needed to compute the audit row diff at transaction completion. Later collection changes for the same role and owner id are represented by the collection wrapper's final state, not by replacing the stored snapshot.

    • entityChanges

      public List<AuditChangeSet.EntityChange<E>> entityChanges()
      Return the merged entity audit changes in encounter order.
    • collectionChanges

      public List<AuditChangeSet.CollectionChange<C>> collectionChanges()
      Return the recorded collection audit changes in encounter order.
    • isEmpty

      public boolean isEmpty()
    • clear

      public void clear()