Class DefaultAuditStrategy

java.lang.Object
org.hibernate.envers.strategy.internal.DefaultAuditStrategy
All Implemented Interfaces:
AuditStrategy, AuditStrategy
Direct Known Subclasses:
DefaultAuditStrategy

public class DefaultAuditStrategy extends Object implements AuditStrategy
Default implementation of the AuditStrategy contract.

This strategy handles the persistence of audit entity data in a very simplistic way.

  • Constructor Details

    • DefaultAuditStrategy

      public DefaultAuditStrategy()
  • Method Details

    • perform

      public void perform(Session session, String entityName, Configuration configuration, Object id, Object data, Object revision)
      Description copied from interface: AuditStrategy
      Perform the persistence of audited data for regular entities.
      Specified by:
      perform in interface AuditStrategy
      Parameters:
      session - Session, which can be used to persist the data.
      entityName - Name of the entity, in which the audited change happens
      configuration - The audit entity configuration.
      id - Id of the entity.
      data - Audit data to persist.
      revision - Current revision data.
    • performCollectionChange

      public void performCollectionChange(Session session, String entityName, String propertyName, Configuration configuration, PersistentCollectionChangeData persistentCollectionChangeData, Object revision)
      Description copied from interface: AuditStrategy
      Perform the persistence of audited data for collection ("middle") entities.
      Specified by:
      performCollectionChange in interface AuditStrategy
      Parameters:
      session - Session, which can be used to persist the data.
      entityName - Name of the entity, in which the audited change happens.
      propertyName - The name of the property holding the persistent collection
      configuration - audit configuration
      persistentCollectionChangeData - Collection change data to be persisted.
      revision - Current revision data
    • addEntityAtRevisionRestriction

      public void addEntityAtRevisionRestriction(Configuration configuration, QueryBuilder rootQueryBuilder, Parameters parameters, String revisionProperty, String revisionEndProperty, boolean addAlias, MiddleIdData idData, String revisionPropertyPath, String originalIdPropertyName, String alias1, String alias2, boolean inclusive)
      Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a two-entity relation. This WHERE clause depends on the AuditStrategy. For this implementation, a subquery is used

      e.revision = (SELECT max(...) ...

      Specified by:
      addEntityAtRevisionRestriction in interface AuditStrategy
      Parameters:
      configuration - the Configuration
      rootQueryBuilder - the QueryBuilder that will be updated
      parameters - root parameters to which restrictions shall be added
      revisionProperty - property of the revision column
      revisionEndProperty - property of the revisionEnd column (only used for ValidityAuditStrategy)
      addAlias - boolean indicator if a left alias is needed
      idData - id-information for the two-entity relation (only used for DefaultAuditStrategy)
      revisionPropertyPath - path of the revision property (only used for ValidityAuditStrategy)
      originalIdPropertyName - name of the id property (only used for ValidityAuditStrategy)
      alias1 - an alias used for subquery (only used for ValidityAuditStrategy)
      alias2 - an alias used for subquery (only used for ValidityAuditStrategy)
      inclusive - indicates whether revision number shall be treated as inclusive or exclusive
    • addAssociationAtRevisionRestriction

      public void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder, Parameters parameters, String revisionProperty, String revisionEndProperty, boolean addAlias, MiddleIdData referencingIdData, String versionsMiddleEntityName, String eeOriginalIdPropertyPath, String revisionPropertyPath, String originalIdPropertyName, String alias1, boolean inclusive, MiddleComponentData... componentDatas)
      Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a middle-entity association. This WHERE clause depends on the AuditStrategy. For this implmeentation, the a subquery is used

      e.revision = (SELECT max(...) ...

      Specified by:
      addAssociationAtRevisionRestriction in interface AuditStrategy
      Parameters:
      rootQueryBuilder - the QueryBuilder that will be updated
      parameters - root parameters to which restrictions shall be added
      revisionProperty - property of the revision column
      revisionEndProperty - property of the revisionEnd column (only used for ValidityAuditStrategy)
      addAlias - boolean indicator if a left alias is needed
      referencingIdData - id-information for the middle-entity association (only used for DefaultAuditStrategy)
      versionsMiddleEntityName - name of the middle-entity
      eeOriginalIdPropertyPath - name of the id property (only used for ValidityAuditStrategy)
      revisionPropertyPath - path of the revision property (only used for ValidityAuditStrategy)
      originalIdPropertyName - name of the id property (only used for ValidityAuditStrategy)
      alias1 - an alias used for subqueries (only used for DefaultAuditStrategy)
      inclusive - indicates whether revision number shall be treated as inclusive or exclusive
      componentDatas - information about the middle-entity relation