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

@ -49,7 +49,7 @@ public class AuditQueryCreator {
/** /**
* Creates a query, which will return entities satisfying some conditions (specified later), * 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 c Class of the entities for which to query.
* @param revision Revision number at which to execute the 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 * @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"); checkNotNull(revision, "Entity revision");
checkPositive(revision, "Entity revision"); checkPositive(revision, "Entity revision");
c = getTargetClassIfProxied(c); 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), * 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 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 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. * @param revision Revision number at which to execute the query.
@ -74,10 +74,7 @@ public class AuditQueryCreator {
* projection is added. * projection is added.
*/ */
public AuditQuery forEntitiesAtRevision(Class<?> c, String entityName, Number revision) { public AuditQuery forEntitiesAtRevision(Class<?> c, String entityName, Number revision) {
checkNotNull(revision, "Entity revision"); return forEntitiesAtRevision(c, entityName, revision, false);
checkPositive(revision, "Entity revision");
c = getTargetClassIfProxied(c);
return new EntitiesAtRevisionQuery(auditCfg, auditReaderImplementor, c, entityName, revision);
} }
/** /**

View File

@ -49,17 +49,10 @@ public class EntitiesAtRevisionQuery extends AbstractAuditQuery {
public EntitiesAtRevisionQuery(AuditConfiguration verCfg, public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
AuditReaderImplementor versionsReader, Class<?> cls, AuditReaderImplementor versionsReader, Class<?> cls,
Number revision) { Number revision, boolean includeDeletions) {
super(verCfg, versionsReader, cls); super(verCfg, versionsReader, cls);
this.revision = revision; 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, public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
@ -102,8 +95,8 @@ public class EntitiesAtRevisionQuery extends AbstractAuditQuery {
verEntCfg.getRevisionEndFieldName(), true, referencedIdData, verEntCfg.getRevisionEndFieldName(), true, referencedIdData,
revisionPropertyPath, originalIdPropertyName, REFERENCED_ENTITY_ALIAS, REFERENCED_ENTITY_ALIAS_DEF_AUD_STR); revisionPropertyPath, originalIdPropertyName, REFERENCED_ENTITY_ALIAS, REFERENCED_ENTITY_ALIAS_DEF_AUD_STR);
// e.revision_type != DEL
if (!includeDeletions) { if (!includeDeletions) {
// e.revision_type != DEL
qb.getRootParameters().addWhereWithParam(verEntCfg.getRevisionTypePropName(), "<>", RevisionType.DEL); qb.getRootParameters().addWhereWithParam(verEntCfg.getRevisionTypePropName(), "<>", RevisionType.DEL);
} }