longValue = (Long) s.createCriteria( Human.class ).setProjection( Projections.sum( "id" )).uniqueResult(); assertNotNull(longValue); longValue = (Long) s.createCriteria( Human.class ).setProjection( Projections.sum( "intValue" )).uniqueResult(); assertNotNull(longValue); dblValue = (Double) s.createCriteria( Human.class ).setProjection( Projections.sum( "heightInches" )).uniqueResult(); assertNotNull(dblValue); dblValue = (Double) s.createCriteria( Human.class ).setProjection( Projections.sum( "floatValue" )).uniqueResult(); assertNotNull(dblValue); BigInteger bigIValue = (BigInteger) s.createCriteria( Human.class ).setProjection( Projections.sum( "bigIntegerValue" )).uniqueResult(); assertNotNull(bigIValue); BigDecimal bigDValue = (BigDecimal) s.createCriteria( Human.class ).setProjection( Projections.sum( "bigDecimalValue" )).uniqueResult(); assertNotNull(bigDValue);
public Projection toHibernateProjection(Query.Projection gormProjection) { Query.SumProjection avg = (Query.SumProjection) gormProjection; return Projections.sum(avg.getPropertyName()); } });
public Projection toHibernateProjection(Query.Projection gormProjection) { Query.SumProjection avg = (Query.SumProjection) gormProjection; return Projections.sum(avg.getPropertyName()); } });
@Override public ProjectionList sum(String name) { projectionList.add(Projections.sum(calculatePropertyName(name))); return this; }
@Override public Query<T> sum(String... properties) { if (properties != null && properties.length > 0) { for (String property : properties) { this.projections.add(Projections.sum(this.getCriteriaAlias(property))); } } return this; }
/** * Adds a projection that allows the criteria to retrieve the sum of the results of a property * * @param propertyName The name of the property * @param alias The alias to use */ public org.grails.datastore.mapping.query.api.ProjectionList sum(String propertyName, String alias) { final AggregateProjection proj = Projections.sum(calculatePropertyName(propertyName)); addProjectionToList(proj, alias); return this; }
/** * Adds a projection that allows the criteria to retrieve the sum of the results of a property * * @param propertyName The name of the property * @param alias The alias to use */ public org.grails.datastore.mapping.query.api.ProjectionList sum(String propertyName, String alias) { final AggregateProjection proj = Projections.sum(calculatePropertyName(propertyName)); addProjectionToList(proj, alias); return this; }
@Override public ProjectionList sum(String name) { projectionList.add(Projections.sum(calculatePropertyName(name))); return this; }
@Override public Long countVulns(Integer orgId, Set<Integer> appIds, Set<Integer> teamIds) { Criteria criteria = getSearchAppCriteria(orgId, null); addFiltering(criteria, teamIds, appIds); return (Long) criteria.setProjection(Projections.sum("totalVulnCount")) .uniqueResult(); }
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); }