/** * Creates a property avg projection * * @return The projection * * @see Projections#avg */ public AggregateProjection avg() { return Projections.avg( getPropertyName() ); }
dblValue = (Double) s.createCriteria( Human.class ).setProjection( Projections.avg( "heightInches" )).uniqueResult(); assertNotNull(dblValue); dblValue = (Double) s.createCriteria( Human.class ).setProjection( Projections.avg( "id" )).uniqueResult(); assertNotNull(dblValue); dblValue = (Double) s.createCriteria( Human.class ).setProjection( Projections.avg( "bigIntegerValue" )).uniqueResult(); assertNotNull(dblValue);
public Projection toHibernateProjection(Query.Projection gormProjection) { Query.AvgProjection avg = (Query.AvgProjection) gormProjection; return Projections.avg(avg.getPropertyName()); } });
public Projection toHibernateProjection(Query.Projection gormProjection) { Query.AvgProjection avg = (Query.AvgProjection) gormProjection; return Projections.avg(avg.getPropertyName()); } });
@Override public ProjectionList avg(String name) { projectionList.add(Projections.avg(calculatePropertyName(name))); return this; }
public AggregateProjection avg() { return Projections.avg(getPropertyName()); }
public AggregateProjection avg() { return Projections.avg(getPropertyName()); }
public AggregateProjection avg() { return Projections.avg(getPropertyName()); }
public AggregateProjection avg() { return Projections.avg(getPropertyName()); }
@Override public Query<T> avg(String... properties) { if (properties != null && properties.length > 0) { for (String property : properties) { this.projections.add(Projections.avg(this.getCriteriaAlias(property))); } } return this; }
/** * Adds a projection that allows the criteria to return the property average value * * @param propertyName The name of the property * @param alias The alias to use */ public org.grails.datastore.mapping.query.api.ProjectionList avg(String propertyName, String alias) { final AggregateProjection aggregateProjection = Projections.avg(calculatePropertyName(propertyName)); addProjectionToList(aggregateProjection, alias); return this; }
/** * Adds a projection that allows the criteria to return the property average value * * @param propertyName The name of the property * @param alias The alias to use */ public org.grails.datastore.mapping.query.api.ProjectionList avg(String propertyName, String alias) { final AggregateProjection aggregateProjection = Projections.avg(calculatePropertyName(propertyName)); addProjectionToList(aggregateProjection, alias); return this; }
@Override public ProjectionList avg(String name) { projectionList.add(Projections.avg(calculatePropertyName(name))); return this; }
private void addStatProjection(Criteria criteria) throws PersistenceException { ProjectionList projList = Projections.projectionList(); projList.add(Projections.rowCount()); for (ColumnStat<T> column : statResult) { if ( column.isCountNotNullFlag()) { projList.add(Projections.count(column.getColumn().getName())); } if ( column.isMinFlag() ) { projList.add(Projections.min(column.getColumn().getName())); } if ( column.isMaxFlag() ) { projList.add(Projections.max(column.getColumn().getName())); } if ( column.isAverageFlag() ) { projList.add(Projections.avg(column.getColumn().getName())); } if ( column.isSumFlag() ) { projList.add(Projections.sum(column.getColumn().getName())); } } criteria.setProjection(projList); }