.add( Property.forName("salary").gt( new BigDecimal(100) ) ) .list(); assertEquals( result.size(), 1 );
.add( Property.forName("salary").gt( new BigDecimal(100) ) ) .list(); assertEquals( result.size(), 1 );
@Override public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery, Query.GreaterThan criterion, String alias) { String propertyName = getPropertyName(criterion, alias); Object value = criterion.getValue(); if (value instanceof DetachedCriteria) { return Property.forName(propertyName).gt((DetachedCriteria) value); } return Restrictions.gt(propertyName, value); } });
@Override public org.hibernate.criterion.Criterion toHibernateCriterion(HibernateQuery hibernateQuery, Query.Criterion criterion, String alias) { Query.GreaterThan eq = (Query.GreaterThan) criterion; Object value = eq.getValue(); if (value instanceof DetachedCriteria) { return Property.forName(calculatePropertyName(eq.getProperty(), alias)).gt((DetachedCriteria)value); } return Restrictions.gt(calculatePropertyName(eq.getProperty(), alias), value); } });
int fromYear, fromMonth, toYear, toMonth; Property year = Property.forName("year"); Property month = Property.forName("month"); session.createCriteria(CommissionSummary.class).add(Restrictions.disjunction() .add(Restrictions.and(year.eq(fromYear), month.ge(fromMonth)) .add(Restrictions.and(year.gt(fromYear), year.lt(toYear)) .add(Restrictions.and(year.eq(toYear), month.le(toMonth)) );
/** * Creates a "greater than" Criterion based on the specified property name and value * @param propertyName The property name * @param propertyValue The property value * @return A Criterion instance */ public org.grails.datastore.mapping.query.api.Criteria gt(String propertyName, Object propertyValue) { if (!validateSimpleExpression()) { throwRuntimeException(new IllegalArgumentException("Call to [gt] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here.")); } propertyName = calculatePropertyName(propertyName); propertyValue = calculatePropertyValue(propertyValue); Criterion gt; if (propertyValue instanceof org.hibernate.criterion.DetachedCriteria) { gt = Property.forName(propertyName).gt((org.hibernate.criterion.DetachedCriteria)propertyValue); } else { gt = Restrictions.gt(propertyName, propertyValue); } addToCriteria(gt); return this; }
/** * Creates a "greater than" Criterion based on the specified property name and value * @param propertyName The property name * @param propertyValue The property value * @return A Criterion instance */ public org.grails.datastore.mapping.query.api.Criteria gt(String propertyName, Object propertyValue) { if (!validateSimpleExpression()) { throwRuntimeException(new IllegalArgumentException("Call to [gt] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here.")); } propertyName = calculatePropertyName(propertyName); propertyValue = calculatePropertyValue(propertyValue); Criterion gt; if (propertyValue instanceof org.hibernate.criterion.DetachedCriteria) { gt = Property.forName(propertyName).gt((org.hibernate.criterion.DetachedCriteria)propertyValue); } else { gt = Restrictions.gt(propertyName, propertyValue); } addToCriteria(gt); return this; }