/** * Get an expression representing the current date as a DateExpression instance * * @return */ public static DateExpression<Date> currentDate() { return DateExpression.currentDate(); }
/** * Truncate the given date expression * * @param unit * @param expr */ public static <D extends Comparable> DateExpression<D> datetrunc(DatePart unit, DateExpression<D> expr) { return DateOperation.create(expr.getType(), DATE_TRUNC_OPS.get(unit), expr); }
/** * Get the maximum value of this expression (aggregation) * * @return max(this) */ public DateExpression<T> max() { if (max == null) { max = DateOperation.create(getType(), Ops.AggOps.MAX_AGG, mixin); } return max; }
@Test public void CurrentDate() { assertToString("current_date", DateExpression.currentDate()); }
@Override public DateExpression<T> as(Path<T> alias) { return DateOperation.create((Class<T>)getType(), Ops.ALIAS, mixin, alias); }
@Test public void BeforeAndAfter() throws RecognitionException, TokenStreamException { ComparableExpression<java.util.Date> ed = catalog.effectiveDate; query() .from(catalog) .where( ed.gt(DateExpression.currentDate()), ed.goe(DateExpression.currentDate()), ed.lt(DateExpression.currentDate()), ed.loe(DateExpression.currentDate())) .select(catalog).parse(); }
/** * Get the minimum value of this expression (aggregation) * * @return min(this) */ public DateExpression<T> min() { if (min == null) { min = DateOperation.create(getType(), Ops.AggOps.MIN_AGG, mixin); } return min; }
@Test @ExcludeIn(Target.HSQLDB) public void No_From() { assertNotNull(query().singleResult(DateExpression.currentDate())); }
/** * Get a dateadd(unit, date, amount) expression * * @param unit * @param date * @param amount * @return */ public static <D extends Comparable> DateExpression<D> dateadd(DatePart unit, DateExpression<D> date, int amount) { return DateOperation.create((Class)date.getType(), DATE_ADD_OPS.get(unit), date, ConstantImpl.create(amount)); }
@Test public void DocoExamples912() throws Exception { query().from(ord, cust) .join(ord.lineItems, item).join(item.product, product) .from(catalog).join(catalog.prices, price).where( ord.paid.not().and(ord.customer.eq(cust)).and( price.product.eq(product)).and( catalog.effectiveDate.gt(DateExpression.currentDate())).and( catalog.effectiveDate.gtAny( sub().from(catalog).where( catalog.effectiveDate.lt(DateExpression.currentDate())) .list(catalog.effectiveDate)))) .groupBy(ord).having(price.amount.sum().gt(0l)) .orderBy(price.amount.sum().desc()) .select(ord.id, price.amount.sum(), item.count()); Customer c1 = new Customer(); Catalog c2 = new Catalog(); query().from(ord) .join(ord.lineItems, item).join(item.product, product) .from(catalog).join(catalog.prices, price).where( ord.paid.not().and(ord.customer.eq(c1)).and( price.product.eq(product)).and(catalog.eq(c2))) .groupBy(ord).having(price.amount.sum().gt(0l)) .orderBy(price.amount.sum().desc()) .select(ord.id, price.amount.sum(), item.count()); }
/** * Add the given amount of days to the date * * @param date * @param days * @return */ public static <D extends Comparable> DateExpression<D> addDays(DateExpression<D> date, int days) { return DateOperation.create((Class)date.getType(), Ops.DateTimeOps.ADD_DAYS, date, ConstantImpl.create(days)); }
@SuppressWarnings("unchecked") @Override public <RT extends Comparable<?>> DateSubQuery<RT> unique(DateExpression<RT> projection) { return new DateSubQuery<RT>((Class)projection.getType(), uniqueProjection(projection)); }
/** * Add the given amount of months to the date * * @param date * @param months * @return */ public static <D extends Comparable> DateExpression<D> addMonths(DateExpression<D> date, int months) { return DateOperation.create((Class)date.getType(), Ops.DateTimeOps.ADD_MONTHS, date, ConstantImpl.create(months)); }
/** * Add the given amount of weeks to the date * * @param date * @param weeks * @return */ public static <D extends Comparable> DateExpression<D> addWeeks(DateExpression<D> date, int weeks) { return DateOperation.create((Class)date.getType(), Ops.DateTimeOps.ADD_WEEKS, date, ConstantImpl.create(weeks)); }
/** * Add the given amount of years to the date * * @param date * @param years * @return */ public static <D extends Comparable> DateExpression<D> addYears(DateExpression<D> date, int years) { return DateOperation.create((Class)date.getType(), Ops.DateTimeOps.ADD_YEARS, date, ConstantImpl.create(years)); }