org.hibernate.envers.strategy
Class ValidityAuditStrategy

java.lang.Object
  extended by org.hibernate.envers.strategy.ValidityAuditStrategy
All Implemented Interfaces:
AuditStrategy
Direct Known Subclasses:
ValidTimeAuditStrategy

public class ValidityAuditStrategy
extends Object
implements AuditStrategy

Audit strategy which persists and retrieves audit information using a validity algorithm, based on the start-revision and end-revision of a row in the audit tables.

This algorithm works as follows:

This has a few important consequences that need to be judged against against each other:

Author:
Stephanie Pau, Adam Warski (adam at warski dot org)

Constructor Summary
ValidityAuditStrategy()
           
 
Method Summary
 void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder, String revisionProperty, String revisionEndProperty, boolean addAlias, MiddleIdData referencingIdData, String versionsMiddleEntityName, String eeOriginalIdPropertyPath, String revisionPropertyPath, String originalIdPropertyName, MiddleComponentData... componentDatas)
          Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a middle-entity association.
 void addEntityAtRevisionRestriction(GlobalConfiguration globalCfg, QueryBuilder rootQueryBuilder, String revisionProperty, String revisionEndProperty, boolean addAlias, MiddleIdData idData, String revisionPropertyPath, String originalIdPropertyName, String alias1, String alias2)
          Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a two-entity relation.
 void perform(Session session, String entityName, AuditConfiguration auditCfg, Serializable id, Object data, Object revision)
          Perform the persistence of audited data for regular entities.
 void performCollectionChange(Session session, AuditConfiguration auditCfg, PersistentCollectionChangeData persistentCollectionChangeData, Object revision)
          Perform the persistence of audited data for collection ("middle") entities.
 void setRevisionTimestampGetter(Getter revisionTimestampGetter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidityAuditStrategy

public ValidityAuditStrategy()
Method Detail

perform

public void perform(Session session,
                    String entityName,
                    AuditConfiguration auditCfg,
                    Serializable 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
auditCfg - Audit configuration
id - Id of the entity.
data - Audit data to persist
revision - Current revision data

performCollectionChange

public void performCollectionChange(Session session,
                                    AuditConfiguration auditCfg,
                                    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.
auditCfg - Audit configuration
persistentCollectionChangeData - Collection change data to be persisted.
revision - Current revision data

addEntityAtRevisionRestriction

public void addEntityAtRevisionRestriction(GlobalConfiguration globalCfg,
                                           QueryBuilder rootQueryBuilder,
                                           String revisionProperty,
                                           String revisionEndProperty,
                                           boolean addAlias,
                                           MiddleIdData idData,
                                           String revisionPropertyPath,
                                           String originalIdPropertyName,
                                           String alias1,
                                           String alias2)
Description copied from interface: AuditStrategy
Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a two-entity relation. This WHERE clause depends on the AuditStrategy, as follows:

Specified by:
addEntityAtRevisionRestriction in interface AuditStrategy
Parameters:
globalCfg - the GlobalConfiguration
rootQueryBuilder - the QueryBuilder that will be updated
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)

addAssociationAtRevisionRestriction

public void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder,
                                                String revisionProperty,
                                                String revisionEndProperty,
                                                boolean addAlias,
                                                MiddleIdData referencingIdData,
                                                String versionsMiddleEntityName,
                                                String eeOriginalIdPropertyPath,
                                                String revisionPropertyPath,
                                                String originalIdPropertyName,
                                                MiddleComponentData... componentDatas)
Description copied from interface: AuditStrategy
Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a middle-entity association. This WHERE clause depends on the AuditStrategy, as follows:

Specified by:
addAssociationAtRevisionRestriction in interface AuditStrategy
Parameters:
rootQueryBuilder - the QueryBuilder that will be updated
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)
componentDatas - information about the middle-entity relation

setRevisionTimestampGetter

public void setRevisionTimestampGetter(Getter revisionTimestampGetter)


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.