Exemple #1
0
 @Override
 public <E extends T> Selection<? extends Scalar<Integer>> count(Class<E> type) {
   checkClosed();
   Objects.requireNotNull(type);
   return new QueryElement<>(SELECT, entityModel, countOperation)
       .select(Count.count(type))
       .from(type);
 }
Exemple #2
0
  @Test
  public void testQuerySelectCount() {
    data.insert(randomPersons(10));
    try (Result<Tuple> result = data.select(Count.count(Person.class).as("bb")).get()) {
      assertTrue(result.first().get("bb").equals(10));
    }
    try (Result<Tuple> result = data.select(Count.count(Person.class)).get()) {
      assertTrue(result.first().get(0).equals(10));
    }
    assertEquals(10, data.count(Person.class).get().value().intValue());

    data.count(Person.class)
        .get()
        .consume(
            new Consumer<Integer>() {
              @Override
              public void accept(Integer integer) {
                assertTrue(integer == 10);
              }
            });
  }
Exemple #3
0
 @Override
 public Selection<? extends Scalar<Integer>> count(QueryAttribute<?, ?>... attributes) {
   checkClosed();
   return new QueryElement<>(SELECT, entityModel, countOperation).select(Count.count(attributes));
 }