@Test public void OrderExpressionInFunctionalWay() { cat.bodyWeight.asc(); cat.bodyWeight.add(kitten.bodyWeight).asc(); }
@Test public void OrderBy() { JPQLQuery query = query().from(cat1).where(cat1.alive); NumberSubQuery<Double> subquery = sub().from(cat).where(cat.mate.id.eq(cat1.id)).unique(cat.floatProperty.avg()); query.orderBy(subquery.subtract(-1.0f).asc()); assertEquals("select cat1 from Cat cat1 where cat1.alive order by (select avg(cat.floatProperty) from Cat cat where cat.mate.id = cat1.id) - ?1 asc", query.toString().replace("\n", " ")); }
@Test @Ignore public void OrderBy() throws Exception { // NOT SUPPORTED query().from(qat).orderBy(qat.toes.avg().asc()).parse(); }
@Test @NoBatooJPA // can't be parsed public void Order_StringValue_ToBigInteger() { int count = (int)query().from(cat).count(); assertEquals(count, query().from(cat).orderBy(cat.id.stringValue().castToNum(BigInteger.class).asc()).list(cat).size()); }
@Test @NoOpenJPA public void OrderBy_2() throws Exception { query().from(an).orderBy(an.bodyWeight.sqrt().divide(2.0).asc()).parse(); }
@Test @NoBatooJPA // can't be parsed public void Order_StringValue_To_Integer() { int count = (int)query().from(cat).count(); assertEquals(count, query().from(cat).orderBy(cat.id.stringValue().castToNum(Integer.class).asc()).list(cat).size()); }
@Test @NoBatooJPA // can't be parsed public void Order_StringValue_ToLong() { int count = (int)query().from(cat).count(); assertEquals(count, query().from(cat).orderBy(cat.id.stringValue().castToNum(Long.class).asc()).list(cat).size()); }
@Test @NoEclipseLink public void GroupBy_YearMonth() { query().from(cat) .groupBy(cat.birthdate.yearMonth()) .orderBy(cat.birthdate.yearMonth().asc()) .list(cat.id.count()); }
@Test public void order_by_ordinal() throws IOException { session.save(new Note(NoteType.A)); session.save(new Note(NoteType.B)); session.flush(); assertEquals( Arrays.asList(null, NoteType.TYPE1, NoteType.A, NoteType.B), session.from($(n)).orderBy($(n.getType()).ordinal().asc()).list($(n.getType()))); }
@Test @Ignore public void DocoExamples910_3() throws Exception { query().from(cat).join(cat.kittens, kitten) .groupBy(cat) .having(kitten.weight.avg().gt(100.0)) .orderBy(kitten.count().asc(), kitten.weight.sum().desc()) .select(cat) .parse(); }
@Test public void CaseBuilder() { QCat cat2 = new QCat("cat2"); NumberExpression<Integer> casex = new CaseBuilder() .when(cat.weight.isNull().and(cat.weight.isNull())).then(0) .when(cat.weight.isNull()).then(cat2.weight) .when(cat2.weight.isNull()).then(cat.weight) .otherwise(cat.weight.add(cat2.weight)); query().from(cat, cat2).orderBy(casex.asc()).list(cat.id, cat2.id); query().from(cat, cat2).orderBy(casex.desc()).list(cat.id, cat2.id); }