@Override public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery, Query.GreaterThanEquals criterion, String alias) { String propertyName = getPropertyName(criterion, alias); Object value = criterion.getValue(); if(value instanceof DetachedCriteria) { return Property.forName(propertyName).ge((DetachedCriteria) value); } return Restrictions.ge(propertyName, value); } });
@Override public List<BlockLocationRecord> doInHibernate(Session session) throws HibernateException, SQLException { Criteria c = session.createCriteria(BlockLocationRecord.class); if (blockId != null) c.add(Property.forName("blockId").eq(blockId)); if (tripId != null) c.add(Property.forName("tripId").eq(tripId)); if (vehicleId != null) c.add(Property.forName("vehicleId").eq(vehicleId)); if (serviceDate != 0) c.add(Property.forName("serviceDate").eq(serviceDate)); if (fromTime != 0) c.add(Property.forName("time").ge(fromTime)); if (toTime != 0) c.add(Property.forName("time").le(toTime)); if (recordLimit != 0) c.setFetchSize(recordLimit); c.addOrder(Order.asc("time")); return c.list(); } });
@Override public List<BlockLocationRecord> doInHibernate(Session session) throws HibernateException, SQLException { Criteria c = session.createCriteria(BlockLocationRecord.class); if (blockId != null) c.add(Property.forName("blockId").eq(blockId)); if (tripId != null) c.add(Property.forName("tripId").eq(tripId)); if (vehicleId != null) c.add(Property.forName("vehicleId").eq(vehicleId)); if (serviceDate != 0) c.add(Property.forName("serviceDate").eq(serviceDate)); if (fromTime != 0) c.add(Property.forName("time").ge(fromTime)); if (toTime != 0) c.add(Property.forName("time").le(toTime)); if (recordLimit != 0) c.setFetchSize(recordLimit); c.addOrder(Order.asc("time")); return c.list(); } });
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.GreaterThanEquals eq = (Query.GreaterThanEquals) criterion; Object value = eq.getValue(); if (value instanceof DetachedCriteria) { return Property.forName(calculatePropertyName(eq.getProperty(), alias)).ge((DetachedCriteria) value); } return Restrictions.ge(calculatePropertyName(eq.getProperty(), alias), value); } });
/** * Creates a "greater than or equal to" 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 ge(String propertyName, Object propertyValue) { if (!validateSimpleExpression()) { throwRuntimeException(new IllegalArgumentException("Call to [ge] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here.")); } propertyName = calculatePropertyName(propertyName); propertyValue = calculatePropertyValue(propertyValue); Criterion ge; if (propertyValue instanceof org.hibernate.criterion.DetachedCriteria) { ge = Property.forName(propertyName).ge((org.hibernate.criterion.DetachedCriteria) propertyValue); } else { ge = Restrictions.ge(propertyName, propertyValue); } addToCriteria(ge); return this; }
/** * Creates a "greater than or equal to" 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 ge(String propertyName, Object propertyValue) { if (!validateSimpleExpression()) { throwRuntimeException(new IllegalArgumentException("Call to [ge] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here.")); } propertyName = calculatePropertyName(propertyName); propertyValue = calculatePropertyValue(propertyValue); Criterion ge; if (propertyValue instanceof org.hibernate.criterion.DetachedCriteria) { ge = Property.forName(propertyName).ge((org.hibernate.criterion.DetachedCriteria) propertyValue); } else { ge = Restrictions.ge(propertyName, propertyValue); } addToCriteria(ge); return this; }
private void addQueryToCriteria(TripProblemReportQueryBean query, Criteria c) { if (query.getAgencyId() != null) { c.add(Property.forName("tripId.agencyId").eq(query.getAgencyId())); } if (query.getTripId() != null) { c.add(Property.forName("tripId").eq( AgencyAndIdLibrary.convertFromString(query.getTripId()))); } if (query.getTimeFrom() != 0) { c.add(Property.forName("time").ge(query.getTimeFrom())); } if (query.getTimeTo() != 0) { c.add(Property.forName("time").le(query.getTimeTo())); } if (query.getStatus() != null) { c.add(Property.forName("status").eq(query.getStatus())); } if (query.getLabel() != null) { c.add(Property.forName("label").eq(query.getLabel())); } } }