/** * Builds a reusable query object for counting rows (Query objects can be executed more * efficiently than creating a QueryBuilder for each execution. */ public CountQuery<T> buildCount() { String tablename = dao.getTablename(); String baseSql = SqlUtils.createSqlSelectCountStar(tablename, tablePrefix); StringBuilder builder = new StringBuilder(baseSql); appendJoinsAndWheres(builder, tablePrefix); String sql = builder.toString(); checkLog(sql); return CountQuery.create(dao, sql, values.toArray()); }
/** * count the entities on column families. * * @param bean the bean * @param session the session * @param consistency the consistency level * @param <T> kind of class * @return the number of entities on column families */ public <T> Long count(Class<T> bean, Session session, ConsistencyLevel consistency) { return countQuery.count(bean, session, consistency); }