}
}
@SuppressWarnings({"unchecked"})
public List list() throws AuditException {
AuditEntitiesConfiguration verEntCfg = verCfg.getAuditEntCfg();
/*
The query that should be executed in the versions table:
SELECT e (unless another projection is specified) FROM ent_ver e, rev_entity r WHERE
e.revision_type != DEL (if selectDeletedEntities == false) AND
e.revision = r.revision AND
(all specified conditions, transformed, on the "e" entity)
ORDER BY e.revision ASC (unless another order or projection is specified)
*/
if ( !selectDeletedEntities ) {
// e.revision_type != DEL AND
qb.getRootParameters().addWhereWithParam( verEntCfg.getRevisionTypePropName(), "<>", RevisionType.DEL );
}
// all specified conditions, transformed
for ( AuditCriterion criterion : criterions ) {
criterion.addToQuery( verCfg, versionsReader, entityName, qb, qb.getRootParameters() );
}
if ( !hasProjection && !hasOrder ) {
String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
qb.addOrder( revisionPropertyPath, true );
}
if ( !selectEntitiesOnly ) {
qb.addFrom( verCfg.getAuditEntCfg().getRevisionInfoEntityName(), "r" );
qb.getRootParameters().addWhere(
verCfg.getAuditEntCfg().getRevisionNumberPath(),
true,
"=",
"r.id",
false
);
}
List<Object> queryResult = buildAndExecuteQuery();
if ( hasProjection ) {
return queryResult;
}
else {
List entities = new ArrayList();
String revisionTypePropertyName = verEntCfg.getRevisionTypePropName();
for ( Object resultRow : queryResult ) {
Map versionsEntity;
Object revisionData;