HHH-7827 - Documentation

This commit is contained in:
Lukasz Antoniak 2012-12-05 10:08:13 +01:00
parent 516577ea80
commit da32690828
3 changed files with 9 additions and 6 deletions

View File

@ -898,7 +898,9 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]></programlist
<para>
The <literal>minimize()</literal> and <literal>maximize()</literal> methods return a criteria,
to which you can add constraints, which must be met by the entities with the
maximized/minimized properties.
maximized/minimized properties. <literal>AggregatedAuditExpression#computeAggregationInInstanceContext()</literal>
enables the possibility to compute aggregated expression in the context of each entity instance
separately. It turns out useful when querying for latest revisions of all entities of a particular type.
</para>
<para>

View File

@ -37,8 +37,7 @@ import org.hibernate.envers.tools.query.QueryBuilder;
public class AggregatedAuditExpression implements AuditCriterion, ExtendableCriterion {
private PropertyNameGetter propertyNameGetter;
private AggregatedMode mode;
// Correlate subquery with outer query by entity id.
private boolean correlate = false;
private boolean correlate = false; // Correlate subquery with outer query by entity id.
private List<AuditCriterion> criterions;
public AggregatedAuditExpression(PropertyNameGetter propertyNameGetter, AggregatedMode mode) {
@ -98,10 +97,12 @@ public class AggregatedAuditExpression implements AuditCriterion, ExtendableCrit
}
/**
* Correlates aggregated subquery with the main query by entity id.
* Compute aggregated expression in the context of each entity instance separately. Useful for retrieving latest
* revisions of all entities of a particular type.<br/>
* Implementation note: Correlates subquery with the outer query by entity id.
* @return this (for method chaining).
*/
public AggregatedAuditExpression correlateSubquery() {
public AggregatedAuditExpression computeAggregationInInstanceContext() {
correlate = true;
return this;
}

View File

@ -189,7 +189,7 @@ public class MaximalizePropertyQuery extends BaseEnversJPAFunctionalTestCase {
public void testAllLatestRevisionsOfEntityType() {
List result = getAuditReader().createQuery()
.forRevisionsOfEntity( StrIntTestEntity.class, false, true )
.add( AuditEntity.revisionNumber().maximize().correlateSubquery() )
.add( AuditEntity.revisionNumber().maximize().computeAggregationInInstanceContext() )
.addOrder( AuditEntity.property( "id" ).asc() )
.getResultList();