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. <p>This algorithm works as follows: <ul> <li>For a <strong>new row</strong> that is persisted in an audit table, only the <strong>start-revision</strong> column of that row is set</li> <li>At the same time the <strong>end-revision</strong> field of the <strong>previous</strong> audit row is set to this revision</li> <li>Queries are retrieved using 'between start and end revision', instead of a subquery.</li> </ul> </p> <p/> <p> This has a few important consequences that need to be judged against against each other: <ul> <li>Persisting audit information is a bit slower, because an extra row is updated</li> <li>Retrieving audit information is a lot faster</li> </ul> </p>
| Constructor and Description |
|---|
ValidityAuditStrategy() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAssociationAtRevisionRestriction(org.hibernate.envers.internal.tools.query.QueryBuilder rootQueryBuilder,
org.hibernate.envers.internal.tools.query.Parameters parameters,
String revisionProperty,
String revisionEndProperty,
boolean addAlias,
org.hibernate.envers.internal.entities.mapper.relation.MiddleIdData referencingIdData,
String versionsMiddleEntityName,
String eeOriginalIdPropertyPath,
String revisionPropertyPath,
String originalIdPropertyName,
String alias1,
boolean inclusive,
org.hibernate.envers.internal.entities.mapper.relation.MiddleComponentData... componentDatas)
Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a middle-entity
association.
|
void |
addEntityAtRevisionRestriction(org.hibernate.envers.configuration.internal.GlobalConfiguration globalCfg,
org.hibernate.envers.internal.tools.query.QueryBuilder rootQueryBuilder,
org.hibernate.envers.internal.tools.query.Parameters parameters,
String revisionProperty,
String revisionEndProperty,
boolean addAlias,
org.hibernate.envers.internal.entities.mapper.relation.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.
|
void |
perform(org.hibernate.Session session,
String entityName,
org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration audEntitiesCfg,
Serializable id,
Object data,
Object revision)
Perform the persistence of audited data for regular entities.
|
void |
performCollectionChange(org.hibernate.Session session,
String entityName,
String propertyName,
org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration auditEntitiesConfiguration,
org.hibernate.envers.internal.entities.mapper.PersistentCollectionChangeData persistentCollectionChangeData,
Object revision)
Perform the persistence of audited data for collection ("middle") entities.
|
void |
setRevisionTimestampGetter(org.hibernate.property.access.spi.Getter revisionTimestampGetter) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitperform, performCollectionChangepublic void perform(org.hibernate.Session session,
String entityName,
org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration audEntitiesCfg,
Serializable id,
Object data,
Object revision)
AuditStrategyPerform the persistence of audited data for regular entities.
perform in interface AuditStrategysession - Session, which can be used to persist the data.entityName - Name of the entity, in which the audited change happensaudEntitiesCfg - The audit entity configuration.id - Id of the entity.data - Audit data to persist.revision - Current revision data.public void performCollectionChange(org.hibernate.Session session,
String entityName,
String propertyName,
org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration auditEntitiesConfiguration,
org.hibernate.envers.internal.entities.mapper.PersistentCollectionChangeData persistentCollectionChangeData,
Object revision)
AuditStrategyPerform the persistence of audited data for collection ("middle") entities.
performCollectionChange in interface AuditStrategysession - 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 collectionauditEntitiesConfiguration - audit entity configurationpersistentCollectionChangeData - Collection change data to be persisted.revision - Current revision datapublic void addEntityAtRevisionRestriction(org.hibernate.envers.configuration.internal.GlobalConfiguration globalCfg,
org.hibernate.envers.internal.tools.query.QueryBuilder rootQueryBuilder,
org.hibernate.envers.internal.tools.query.Parameters parameters,
String revisionProperty,
String revisionEndProperty,
boolean addAlias,
org.hibernate.envers.internal.entities.mapper.relation.MiddleIdData idData,
String revisionPropertyPath,
String originalIdPropertyName,
String alias1,
String alias2,
boolean inclusive)
AuditStrategyUpdate 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:
<ul>
<li>For DefaultAuditStrategy a subquery is created:
<p><code>e.revision = (SELECT max(…) …)</code></p>
</li>
<li>for ValidityAuditStrategy the revision-end column is used:
<p><code>e.revision ⇐ :revision and (e.endRevision > :revision or e.endRevision is null)</code></p>
</li>
</ul>
addEntityAtRevisionRestriction in interface AuditStrategyglobalCfg - the GlobalConfigurationrootQueryBuilder - the QueryBuilder that will be updatedparameters - root parameters to which restrictions shall be addedrevisionProperty - property of the revision columnrevisionEndProperty - property of the revisionEnd column (only used for ValidityAuditStrategy)addAlias - boolean indicator if a left alias is neededidData - 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 exclusivepublic void addAssociationAtRevisionRestriction(org.hibernate.envers.internal.tools.query.QueryBuilder rootQueryBuilder,
org.hibernate.envers.internal.tools.query.Parameters parameters,
String revisionProperty,
String revisionEndProperty,
boolean addAlias,
org.hibernate.envers.internal.entities.mapper.relation.MiddleIdData referencingIdData,
String versionsMiddleEntityName,
String eeOriginalIdPropertyPath,
String revisionPropertyPath,
String originalIdPropertyName,
String alias1,
boolean inclusive,
org.hibernate.envers.internal.entities.mapper.relation.MiddleComponentData... componentDatas)
AuditStrategyUpdate 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:
<ul>
<li>For DefaultAuditStrategy a subquery is created:
<p><code>e.revision = (SELECT max(…) …)</code></p>
</li>
<li>for ValidityAuditStrategy the revision-end column is used:
<p><code>e.revision ⇐ :revision and (e.endRevision > :revision or e.endRevision is null)</code></p>
</li>
</ul>
addAssociationAtRevisionRestriction in interface AuditStrategyrootQueryBuilder - the QueryBuilder that will be updatedparameters - root parameters to which restrictions shall be addedrevisionProperty - property of the revision columnrevisionEndProperty - property of the revisionEnd column (only used for ValidityAuditStrategy)addAlias - boolean indicator if a left alias is neededreferencingIdData - id-information for the middle-entity association (only used for DefaultAuditStrategy)versionsMiddleEntityName - name of the middle-entityeeOriginalIdPropertyPath - 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 exclusivecomponentDatas - information about the middle-entity relationpublic void setRevisionTimestampGetter(org.hibernate.property.access.spi.Getter revisionTimestampGetter)
Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.