HHH-5580 - Cleanup

This commit is contained in:
Lukasz Antoniak 2011-05-21 12:49:37 +02:00
parent 403b15cae8
commit c2e53061f2
12 changed files with 53 additions and 54 deletions

View File

@ -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>

View File

@ -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:

View File

@ -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 {
* &lt;/set&gt;
* </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");

View File

@ -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;
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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)
*/

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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)
*/