@Test public void testCountFunction_withSpecifiedField_plusOneSelect_inverse() { Entity from = from(Entity.class); Query<Object[]> select = select(from.getCode(), count(from.getCode())); assertEquals( "select entity_0.code, count(entity_0.code) from Entity entity_0", select.getQuery()); }
@Test public void testSpecifyFieldBeforeFunctionCount() { Entity from = from(Entity.class); groupBy(from.getCode()); Query<Object[]> select = select(from.getCode(), count(from)); assertEquals( "select entity_0.code, count(entity_0) from Entity entity_0 group by entity_0.code", select.getQuery()); }
@Test public void testCoalesceFunction() { Entity from = from(Entity.class); Query<String> select = select(coalesce(from.getCode(), from.getName())); assertEquals( "select coalesce(entity_0.code,entity_0.name) from Entity entity_0", select.getQuery()); }
@Test public void testFunctionOnObjectWithoutConstructor() { Entity from = from(Entity.class); groupBy(from.getCode()); Query<BigDecimal> select = select(sum(from.getBigDecimalField())); assertEquals( "select sum(entity_0.bigDecimalField) from Entity entity_0 group by entity_0.code", select.getQuery()); }
@Test public void testCountFunction_withSpecifiedField() { Entity from = from(Entity.class); Query<Long> select = select(count(from.getCode())); assertEquals("select count(entity_0.code) from Entity entity_0", select.getQuery()); }
@Test public void testDistinctOnField() { Entity from = from(Entity.class); Query<String> select = select(distinct(from.getCode())); assertEquals("select distinct entity_0.code from Entity entity_0", select.getQuery()); }