Class ValidityAuditStrategy
java.lang.Object
org.hibernate.envers.strategy.internal.ValidityAuditStrategy
- All Implemented Interfaces:
AuditStrategy,AuditStrategy
- Direct Known Subclasses:
ValidityAuditStrategy
An audit strategy implementation that persists and fetches audit information using a validity
algorithm, based on the start-revision and end-revision of a row in the audit table schema.
This algorithm works as follows:
- For a new row, only the start-revision column is set in the row.
- Concurrently, the end-revision of the prior audit row is set to the current revision
- Queries using a between start and end revision predicate rather than using subqueries.
This has a few important consequences which must be considered:
- Persisting audit information is sightly slower due to an extra update required
- Retreiving audit information is considerably faster
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalColumns(MappingContext mappingContext) Add additional columns to the audit mappings.voidaddAssociationAtRevisionRestriction(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.voidaddEntityAtRevisionRestriction(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.voidperform(Session session, String entityName, Configuration configuration, Object id, Object data, Object revision) Perform the persistence of audited data for regular entities.voidperformCollectionChange(Session session, String entityName, String propertyName, Configuration configuration, PersistentCollectionChangeData persistentCollectionChangeData, Object revision) Perform the persistence of audited data for collection ("middle") entities.voidpostInitialize(AuditStrategyContext context) Performs post initialization of the audit strategy implementation.voidsetRevisionTimestampGetter(Getter revisionTimestampGetter) Deprecated.with no replacement.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.envers.strategy.AuditStrategy
perform, performCollectionChange
-
Constructor Details
-
ValidityAuditStrategy
public ValidityAuditStrategy()
-
-
Method Details
-
postInitialize
Description copied from interface:AuditStrategyPerforms post initialization of the audit strategy implementation.- Specified by:
postInitializein interfaceAuditStrategy- Parameters:
context- the audit strategy context, nevernull
-
addAdditionalColumns
Description copied from interface:AuditStrategyAdd additional columns to the audit mappings.- Specified by:
addAdditionalColumnsin interfaceAuditStrategy- Parameters:
mappingContext- The mapping context.
-
perform
public void perform(Session session, String entityName, Configuration configuration, Object id, Object data, Object revision) Description copied from interface:AuditStrategyPerform the persistence of audited data for regular entities.- Specified by:
performin interfaceAuditStrategy- Parameters:
session- Session, which can be used to persist the data.entityName- Name of the entity, in which the audited change happensconfiguration- 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:AuditStrategyPerform the persistence of audited data for collection ("middle") entities.- Specified by:
performCollectionChangein interfaceAuditStrategy- 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 collectionconfiguration- audit configurationpersistentCollectionChangeData- 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 implmenetation, the revision-end column is usede.revision <= :revision and (e.endRevision > :revision or e.endRevision is null- Specified by:
addEntityAtRevisionRestrictionin interfaceAuditStrategy- Parameters:
configuration- theConfigurationrootQueryBuilder- theQueryBuilderthat will be updatedparameters- root parameters to which restrictions shall be addedrevisionProperty- property of the revision columnrevisionEndProperty- property of the revisionEnd column (only used forValidityAuditStrategy)addAlias-booleanindicator if a left alias is neededidData- id-information for the two-entity relation (only used forDefaultAuditStrategy)revisionPropertyPath- path of the revision property (only used forValidityAuditStrategy)originalIdPropertyName- name of the id property (only used forValidityAuditStrategy)alias1- an alias used for subquery (only used forValidityAuditStrategy)alias2- an alias used for subquery (only used forValidityAuditStrategy)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 implmenetation, the revision-end column is usede.revision <= :revision and (e.endRevision > :revision or e.endRevision is null- Specified by:
addAssociationAtRevisionRestrictionin interfaceAuditStrategy- Parameters:
rootQueryBuilder- theQueryBuilderthat will be updatedparameters- root parameters to which restrictions shall be addedrevisionProperty- property of the revision columnrevisionEndProperty- property of the revisionEnd column (only used forValidityAuditStrategy)addAlias-booleanindicator if a left alias is neededreferencingIdData- id-information for the middle-entity association (only used forDefaultAuditStrategy)versionsMiddleEntityName- name of the middle-entityeeOriginalIdPropertyPath- name of the id property (only used forValidityAuditStrategy)revisionPropertyPath- path of the revision property (only used forValidityAuditStrategy)originalIdPropertyName- name of the id property (only used forValidityAuditStrategy)alias1- an alias used for subqueries (only used forDefaultAuditStrategy)inclusive- indicates whether revision number shall be treated as inclusive or exclusivecomponentDatas- information about the middle-entity relation
-
setRevisionTimestampGetter
Deprecated.with no replacement.
-