user2415528
user2415528

Reputation: 31

Count query in GridGain

Is there a count query in GridGain?

GridCacheQuery<Map.Entry<Long, Person>> qry =
    queries.createSqlQuery(Person.class, "select count() from Person where street = ?");
int count = qry.execute("streetname").get();

Upvotes: 0

Views: 105

Answers (1)

Dmitriy
Dmitriy

Reputation: 2292

Try SQL fields query which can select specific columns instead of the whole class:

GridCacheQuery<List<?>> qry = queries.createSqlFieldsQuery(
    "select count() from Person where street = ?");

Collection<List<?>> rows = qry.execute("streetname").get();

List<?> firstRow = rows.get(0);

int count = (Integer)firstRow.get(0);

Upvotes: 1

Related Questions