HHH-5580 - Cleanup
This commit is contained in:
parent
403b15cae8
commit
c2e53061f2
|
@ -16,7 +16,7 @@
|
|||
which can be used to identify groups of changes (much like a change set in source control). As the revisions
|
||||
are global, having a revision number, you can query for various entities at that revision, retrieving a
|
||||
(partial) view of the database at that revision. You can find a revision number having a date, and the other
|
||||
way round, you can get the date at which a revision was committed. Since version 4, Envers enables user
|
||||
way round, you can get the date at which a revision was committed. Since version 4.0, Envers enables you
|
||||
to retrieve all changes performed in a certain revision.
|
||||
</para>
|
||||
</preface>
|
||||
|
@ -531,7 +531,7 @@ public class AnnotatedTrackingRevisionEntity {
|
|||
</para>
|
||||
|
||||
<example>
|
||||
<title>Custom implementation of tracking entity classes modified in revision</title>
|
||||
<title>Custom implementation of tracking entity classes modified during revisions</title>
|
||||
<programlisting>
|
||||
<filename>CustomEntityTrackingRevisionListener.java</filename>
|
||||
<![CDATA[
|
||||
|
@ -787,9 +787,9 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]></programlist
|
|||
<section id="envers-tracking-modified-entities-queries">
|
||||
<title>Querying for entities modified in a given revision</title>
|
||||
<para>
|
||||
The basic query allows retrieving entity classes modified in a specified revision:
|
||||
The basic query allows retrieving entity types changed in a specified revision:
|
||||
</para>
|
||||
<programlisting><![CDATA[Set<Class> modifiedEntities = getAuditReader()
|
||||
<programlisting><![CDATA[Set<Class> modifiedEntityTypes = getAuditReader()
|
||||
.findEntityTypesChangedInRevision(revisionNumber);]]></programlisting>
|
||||
<para>
|
||||
Other queries (accessible from <interfacename>org.hibernate.envers.AuditReader</interfacename>):
|
||||
|
@ -816,7 +816,7 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]></programlist
|
|||
</orderedlist>
|
||||
<para>
|
||||
Note that methods described above can be legally used only when default mechanism of
|
||||
tracking changed entity classes is enabled (see <xref linkend="envers-tracking-modified-entities-reventity"/>).
|
||||
tracking changed entity types is enabled (see <xref linkend="envers-tracking-modified-entities-reventity"/>).
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ public interface AuditReader {
|
|||
/**
|
||||
* Checks if the entityName was configured to be audited.
|
||||
*
|
||||
* @param entityName
|
||||
* @param entityClass
|
||||
* EntityName of the entity asking for audit support.
|
||||
* @return true if the entityName is audited.
|
||||
*/
|
||||
|
@ -234,7 +234,7 @@ public interface AuditReader {
|
|||
* where <i>n</i> is a number of different entity classes modified within specified revision.
|
||||
* @param revision Revision number.
|
||||
* @param revisionType Type of modification.
|
||||
* @return Snapshots of all audited entities changed in a given revision filtered by modification type.
|
||||
* @return Snapshots of all audited entities changed in a given revision and filtered by modification type.
|
||||
* @throws IllegalStateException If the associated entity manager is closed.
|
||||
* @throws IllegalArgumentException If a revision number is <code>null</code>, less or equal to 0.
|
||||
* @throws AuditException If none of the following conditions is satisfied:
|
||||
|
|
|
@ -34,7 +34,14 @@ import org.hibernate.annotations.common.reflection.ReflectionManager;
|
|||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
import org.hibernate.annotations.common.reflection.XProperty;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.envers.*;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.envers.DefaultRevisionEntity;
|
||||
import org.hibernate.envers.DefaultTrackingModifiedTypesRevisionEntity;
|
||||
import org.hibernate.envers.ModifiedEntityTypes;
|
||||
import org.hibernate.envers.RevisionEntity;
|
||||
import org.hibernate.envers.RevisionListener;
|
||||
import org.hibernate.envers.RevisionNumber;
|
||||
import org.hibernate.envers.RevisionTimestamp;
|
||||
import org.hibernate.envers.configuration.metadata.AuditTableData;
|
||||
import org.hibernate.envers.configuration.metadata.MetadataTools;
|
||||
import org.hibernate.envers.entities.PropertyData;
|
||||
|
@ -87,7 +94,7 @@ public class RevisionInfoConfiguration {
|
|||
MetadataTools.addColumn(timestampProperty, "REVTSTMP", null, 0, 0, null, null, null, false);
|
||||
|
||||
if (globalCfg.isTrackEntitiesChangedInRevisionEnabled()) {
|
||||
generateEntityNamesTrackingTableMapping(class_mapping, "modifiedEntityTypes", "REVENTITY", "REV", "ENTITYTYPE", "string");
|
||||
generateEntityTypesTrackingTableMapping(class_mapping, "modifiedEntityTypes", "REVENTITY", "REV", "ENTITYTYPE", "string");
|
||||
}
|
||||
|
||||
return document;
|
||||
|
@ -104,7 +111,7 @@ public class RevisionInfoConfiguration {
|
|||
* </set>
|
||||
* </code>
|
||||
*/
|
||||
private void generateEntityNamesTrackingTableMapping(Element class_mapping, String propertyName,
|
||||
private void generateEntityTypesTrackingTableMapping(Element class_mapping, String propertyName,
|
||||
String joinTableName, String joinTablePrimaryKeyColumnName,
|
||||
String joinTableValueColumnName, String joinTableValueColumnType) {
|
||||
Element set = class_mapping.addElement("set");
|
||||
|
|
|
@ -48,8 +48,7 @@ public class EntitiesAtRevisionQuery extends AbstractAuditQuery {
|
|||
}
|
||||
|
||||
public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
|
||||
AuditReaderImplementor versionsReader, Class<?> cls, String entityName,
|
||||
Number revision) {
|
||||
AuditReaderImplementor versionsReader, Class<?> cls, String entityName, Number revision) {
|
||||
super(verCfg, versionsReader, cls, entityName);
|
||||
this.revision = revision;
|
||||
}
|
||||
|
@ -85,9 +84,9 @@ public class EntitiesAtRevisionQuery extends AbstractAuditQuery {
|
|||
verCfg.getAuditStrategy().addEntityAtRevisionRestriction(verCfg.getGlobalCfg(), qb, revisionPropertyPath,
|
||||
verEntCfg.getRevisionEndFieldName(), true, referencedIdData,
|
||||
revisionPropertyPath, originalIdPropertyName, "e", "e2");
|
||||
|
||||
// e.revision_type != DEL
|
||||
qb.getRootParameters().addWhereWithParam(verEntCfg.getRevisionTypePropName(), "<>", RevisionType.DEL);
|
||||
|
||||
// e.revision_type != DEL
|
||||
qb.getRootParameters().addWhereWithParam(verEntCfg.getRevisionTypePropName(), "<>", RevisionType.DEL);
|
||||
|
||||
// all specified conditions
|
||||
for (AuditCriterion criterion : criterions) {
|
||||
|
|
|
@ -24,9 +24,14 @@
|
|||
package org.hibernate.envers.reader;
|
||||
import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull;
|
||||
import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
|
||||
|
||||
import java.lang.reflect.Member;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.persistence.NoResultException;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.HibernateException;
|
||||
|
@ -55,7 +60,6 @@ public class AuditReaderImpl implements AuditReaderImplementor {
|
|||
private final SessionImplementor sessionImplementor;
|
||||
private final Session session;
|
||||
private final FirstLevelCache firstLevelCache;
|
||||
private Member modifiedEntityTypesProperty = null;
|
||||
|
||||
public AuditReaderImpl(AuditConfiguration verCfg, Session session,
|
||||
SessionImplementor sessionImplementor) {
|
||||
|
@ -297,7 +301,7 @@ public class AuditReaderImpl implements AuditReaderImplementor {
|
|||
return Collections.EMPTY_SET;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <T> T getCurrentRevision(Class<T> revisionEntityClass, boolean persist) {
|
||||
if (!(session instanceof EventSource)) {
|
||||
throw new IllegalArgumentException("The provided session is not an EventSource!");
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hibernate.envers.revisioninfo;
|
||||
|
||||
import org.hibernate.envers.DefaultTrackingModifiedTypesRevisionEntity;
|
||||
import org.hibernate.envers.ModifiedEntityTypes;
|
||||
import org.hibernate.envers.RevisionListener;
|
||||
import org.hibernate.envers.RevisionType;
|
||||
import org.hibernate.envers.entities.PropertyData;
|
||||
|
@ -12,17 +14,16 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Automatically adds entity names changed during current revision.
|
||||
* @see org.hibernate.envers.ModifiedEntityTypes
|
||||
* @see org.hibernate.envers.DefaultTrackingModifiedTypesRevisionEntity
|
||||
* Automatically adds entity class names that have been changed during current revision to revision entity.
|
||||
* @see ModifiedEntityTypes
|
||||
* @see DefaultTrackingModifiedTypesRevisionEntity
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
public class DefaultTrackingModifiedTypesRevisionInfoGenerator extends DefaultRevisionInfoGenerator {
|
||||
private final Setter modifiedEntityTypesSetter;
|
||||
private final Getter modifiedEntityTypesGetter;
|
||||
|
||||
public DefaultTrackingModifiedTypesRevisionInfoGenerator(String revisionInfoEntityName,
|
||||
Class<?> revisionInfoClass,
|
||||
public DefaultTrackingModifiedTypesRevisionInfoGenerator(String revisionInfoEntityName, Class<?> revisionInfoClass,
|
||||
Class<? extends RevisionListener> listenerClass,
|
||||
PropertyData revisionInfoTimestampData, boolean timestampAsDate,
|
||||
PropertyData modifiedEntityTypesData) {
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ModifiedEntityTypesReader {
|
|||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public Set<Class> getModifiedEntityTypes(Object revisionEntity) {
|
||||
// The default mechanism of tracking entity types that have been changed during each revision, stores
|
||||
// The default mechanism of tracking entity types that have been changed during each revision stores
|
||||
// fully qualified Java class names.
|
||||
Set<String> modifiedEntityClassNames = (Set<String>) modifiedEntityTypesGetter.get(revisionEntity);
|
||||
if (modifiedEntityClassNames != null) {
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
*/
|
||||
package org.hibernate.envers.synchronization;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
|
||||
|
@ -31,11 +35,6 @@ import org.hibernate.envers.revisioninfo.RevisionInfoGenerator;
|
|||
import org.hibernate.envers.synchronization.work.AuditWorkUnit;
|
||||
import org.hibernate.envers.tools.Pair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
*/
|
||||
package org.hibernate.envers.synchronization.work;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.envers.RevisionType;
|
||||
|
@ -30,10 +33,6 @@ import org.hibernate.envers.configuration.AuditConfiguration;
|
|||
import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
|
||||
import org.hibernate.envers.strategy.AuditStrategy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
* @author Stephanie Pau at Markit Group Plc
|
||||
|
|
|
@ -22,13 +22,11 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.envers.synchronization.work;
|
||||
|
||||
import java.util.Map;
|
||||
import java.io.Serializable;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.envers.RevisionType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TODO: refactor constructors into factory methods
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
|
|
@ -23,8 +23,10 @@
|
|||
*/
|
||||
package org.hibernate.envers.synchronization.work;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.collection.PersistentCollection;
|
||||
import org.hibernate.engine.CollectionEntry;
|
||||
|
@ -79,7 +81,7 @@ public class PersistentCollectionChangeWorkUnit extends AbstractAuditWorkUnit im
|
|||
// Setting the revision number
|
||||
((Map<String, Object>) persistentCollectionChangeData.getData().get(entitiesCfg.getOriginalIdPropName()))
|
||||
.put(entitiesCfg.getRevisionFieldName(), revisionData);
|
||||
|
||||
|
||||
auditStrategy.performCollectionChange(session, verCfg, persistentCollectionChangeData, revisionData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.envers.tools.reflection;
|
||||
|
||||
import static org.hibernate.envers.tools.Pair.make;
|
||||
import java.util.Map;
|
||||
import org.hibernate.envers.entities.PropertyData;
|
||||
import org.hibernate.envers.exception.AuditException;
|
||||
import org.hibernate.envers.tools.ConcurrentReferenceHashMap;
|
||||
|
@ -32,17 +33,6 @@ import org.hibernate.property.PropertyAccessor;
|
|||
import org.hibernate.property.PropertyAccessorFactory;
|
||||
import org.hibernate.property.Setter;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hibernate.envers.tools.Pair.make;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue