HHH-5845 - Cleanup

(cherry picked from commit 4213e3c13a)
This commit is contained in:
Lukasz Antoniak 2013-04-05 11:50:33 +02:00
parent dcf3fa4ff6
commit d35dee771b
3 changed files with 9 additions and 19 deletions

View File

@ -71,7 +71,7 @@ public interface AuditReader {
<T> T find(Class<T> cls, String entityName, Object primaryKey,
Number revision) throws IllegalArgumentException,
NotAuditedException, IllegalStateException;
/**
* Find an entity by primary key at the given revision with the specified entityName,
* possibly including deleted entities in the search.

View File

@ -49,7 +49,7 @@ public class AuditQueryCreator {
/**
* Creates a query, which will return entities satisfying some conditions (specified later),
* at a given revision.
* at a given revision. Deleted entities are not included.
* @param c Class of the entities for which to query.
* @param revision Revision number at which to execute the query.
* @return A query for entities at a given revision, to which conditions can be added and which
@ -60,12 +60,12 @@ public class AuditQueryCreator {
checkNotNull(revision, "Entity revision");
checkPositive(revision, "Entity revision");
c = getTargetClassIfProxied(c);
return new EntitiesAtRevisionQuery(auditCfg, auditReaderImplementor, c, revision);
return new EntitiesAtRevisionQuery(auditCfg, auditReaderImplementor, c, revision, false);
}
/**
* Creates a query, which will return entities satisfying some conditions (specified later),
* at a given revision and a given entityName.
* at a given revision and a given entityName. Deleted entities are not included.
* @param c Class of the entities for which to query.
* @param entityName Name of the entity (if can't be guessed basing on the {@code c}).
* @param revision Revision number at which to execute the query.
@ -74,10 +74,7 @@ public class AuditQueryCreator {
* projection is added.
*/
public AuditQuery forEntitiesAtRevision(Class<?> c, String entityName, Number revision) {
checkNotNull(revision, "Entity revision");
checkPositive(revision, "Entity revision");
c = getTargetClassIfProxied(c);
return new EntitiesAtRevisionQuery(auditCfg, auditReaderImplementor, c, entityName, revision);
return forEntitiesAtRevision(c, entityName, revision, false);
}
/**

View File

@ -49,18 +49,11 @@ public class EntitiesAtRevisionQuery extends AbstractAuditQuery {
public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
AuditReaderImplementor versionsReader, Class<?> cls,
Number revision) {
Number revision, boolean includeDeletions) {
super(verCfg, versionsReader, cls);
this.revision = revision;
this.includeDeletions = false;
this.includeDeletions = includeDeletions;
}
public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
AuditReaderImplementor versionsReader, Class<?> cls, String entityName, Number revision) {
super(verCfg, versionsReader, cls, entityName);
this.revision = revision;
this.includeDeletions = false;
}
public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
AuditReaderImplementor versionsReader, Class<?> cls,
@ -101,9 +94,9 @@ public class EntitiesAtRevisionQuery extends AbstractAuditQuery {
verCfg.getAuditStrategy().addEntityAtRevisionRestriction(verCfg.getGlobalCfg(), qb, revisionPropertyPath,
verEntCfg.getRevisionEndFieldName(), true, referencedIdData,
revisionPropertyPath, originalIdPropertyName, REFERENCED_ENTITY_ALIAS, REFERENCED_ENTITY_ALIAS_DEF_AUD_STR);
// e.revision_type != DEL
if (!includeDeletions) {
// e.revision_type != DEL
qb.getRootParameters().addWhereWithParam(verEntCfg.getRevisionTypePropName(), "<>", RevisionType.DEL);
}