.add(date1Prop.lt(date1Criteria)) .add(Restrictions.or(date2Prop.isNull(), date2Prop.le(date2Criteria))) .addOrder(Order.desc("x"));
@Override public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery, Query.LessThan criterion, String alias) { String propertyName = getPropertyName(criterion, alias); Object value = criterion.getValue(); if (value instanceof DetachedCriteria) { return Property.forName(propertyName).lt((DetachedCriteria) value); } return Restrictions.lt(propertyName, 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)) );
@Override public org.hibernate.criterion.Criterion toHibernateCriterion(HibernateQuery hibernateQuery, Query.Criterion criterion, String alias) { Query.LessThan eq = (Query.LessThan) criterion; Object value = eq.getValue(); if (value instanceof DetachedCriteria) { return Property.forName(calculatePropertyName(eq.getProperty(), alias)).lt((DetachedCriteria) value); } return Restrictions.lt(calculatePropertyName(eq.getProperty(), alias), value); } });
/** * Creates a "less 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 lt(String propertyName, Object propertyValue) { if (!validateSimpleExpression()) { throwRuntimeException(new IllegalArgumentException("Call to [lt] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here.")); } propertyName = calculatePropertyName(propertyName); propertyValue = calculatePropertyValue(propertyValue); Criterion lt; if (propertyValue instanceof org.hibernate.criterion.DetachedCriteria) { lt = Property.forName(propertyName).lt((org.hibernate.criterion.DetachedCriteria) propertyValue); } else { lt = Restrictions.lt(propertyName, propertyValue); } addToCriteria(lt); return this; }
/** * Creates a "less 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 lt(String propertyName, Object propertyValue) { if (!validateSimpleExpression()) { throwRuntimeException(new IllegalArgumentException("Call to [lt] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here.")); } propertyName = calculatePropertyName(propertyName); propertyValue = calculatePropertyValue(propertyValue); Criterion lt; if (propertyValue instanceof org.hibernate.criterion.DetachedCriteria) { lt = Property.forName(propertyName).lt((org.hibernate.criterion.DetachedCriteria) propertyValue); } else { lt = Restrictions.lt(propertyName, propertyValue); } addToCriteria(lt); return this; }