@Override public FilterConditionEndContext having(String attributePath) { return having(Expression.property(attributePath)); }
@Override public QueryBuilder orderBy(String attributePath, SortOrder sortOrder) { return orderBy(Expression.property(attributePath), sortOrder); }
@Override public FilterConditionEndContext having(String attributePath) { return having(Expression.property(attributePath)); }
@Override public FilterConditionEndContext having(String attributePath) { return having(Expression.property(attributePath)); }
@Override public FilterConditionEndContext having(String attributePath) { return having(Expression.property(attributePath)); }
@Override public FilterConditionEndContext having(String attributePath) { return having(Expression.property(attributePath)); }
@Override public FilterConditionEndContext having(String attributePath) { return having(Expression.property(attributePath)); }
@Override public QueryBuilder orderBy(String attributePath, SortOrder sortOrder) { return orderBy(Expression.property(attributePath), sortOrder); }
@Override public QueryBuilder select(String... attributePath) { if (attributePath == null || attributePath.length == 0) { throw log.projectionCannotBeNullOrEmpty(); } Expression[] projection = new Expression[attributePath.length]; for (int i = 0; i < attributePath.length; i++) { projection[i] = Expression.property(attributePath[i]); } return select(projection); }
@Override public QueryBuilder select(String... attributePath) { if (attributePath == null || attributePath.length == 0) { throw log.projectionCannotBeNullOrEmpty(); } Expression[] projection = new Expression[attributePath.length]; for (int i = 0; i < attributePath.length; i++) { projection[i] = Expression.property(attributePath[i]); } return select(projection); }
public void testEmbeddedSum() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getUserImplClass()) .select(property("surname"), sum("addresses.number")) .groupBy("surname") .orderBy("surname") .build(); List<Object[]> list = q.list(); assertEquals(3, list.size()); assertEquals(2, list.get(0).length); assertEquals(2, list.get(1).length); assertEquals(2, list.get(2).length); assertEquals(156L, list.get(0)[1]); assertEquals(300L, list.get(1)[1]); assertNull(list.get(2)[1]); }
public void testCount() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getUserImplClass()) .select(property("surname"), count("age")) .groupBy("surname") .orderBy("surname") .build(); List<Object[]> list = q.list(); assertEquals(3, list.size()); assertEquals(2, list.get(0).length); assertEquals(2, list.get(1).length); assertEquals(2, list.get(2).length); assertEquals(1L, list.get(0)[1]); assertEquals(0L, list.get(1)[1]); assertEquals(0L, list.get(2)[1]); }
public void testAvg() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), avg("amount")) .groupBy("accountId") .orderBy("accountId") .build(); List<Object[]> list = q.list(); assertEquals(2, list.size()); assertEquals(2, list.get(0).length); assertEquals(2, list.get(1).length); assertEquals(1107.6666d, (Double) list.get(0)[1], 0.0001d); assertEquals(120.18867d, (Double) list.get(1)[1], 0.0001d); }
public void testParamWithGroupBy() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), property("date"), sum("amount")) .groupBy("accountId", "date") .having(sum("amount")).gt(param("param")) .build(); q.setParameter("param", 1801); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(3, list.get(0).length); assertEquals(6225d, list.get(0)[2]); }
public void testMin() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), min("amount")) .groupBy("accountId") .orderBy("accountId") .build(); List<Object[]> list = q.list(); assertEquals(2, list.size()); assertEquals(2, list.get(0).length); assertEquals(2, list.get(1).length); assertEquals(23d, list.get(0)[1]); assertEquals(5d, list.get(1)[1]); }
public void testMax() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), max("amount")) .groupBy("accountId") .orderBy("accountId") .build(); List<Object[]> list = q.list(); assertEquals(2, list.size()); assertEquals(2, list.get(0).length); assertEquals(2, list.get(1).length); assertEquals(1800d, list.get(0)[1]); assertEquals(149d, list.get(1)[1]); }
public void testHavingWithAvg() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), avg("amount")) .groupBy("accountId") .having(avg("amount")).lt(130.0) .orderBy("accountId") .build(); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(2, list.get(0)[0]); assertEquals(120.188679d, (Double) list.get(0)[1], 0.0001d); }
public void testHavingWithSum() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), sum("amount")) .groupBy("accountId") .having(sum("amount")).gt(3324) .orderBy("accountId") .build(); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(2, list.get(0)[0]); assertEquals(6370.0d, (Double) list.get(0)[1], 0.0001d); }
public void testHavingWithMin() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), min("amount")) .groupBy("accountId") .having(min("amount")).lt(10) .orderBy("accountId") .build(); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(2, list.get(0)[0]); assertEquals(5.0d, (Double) list.get(0)[1], 0.0001d); }
public void testHavingWithMax() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select(property("accountId"), max("amount")) .groupBy("accountId") .having(avg("amount")).lt(150) .orderBy("accountId") .build(); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(2, list.get(0)[0]); assertEquals(149.0d, (Double) list.get(0)[1], 0.0001d); }