code: public long count(Class<? extends Execution> cls, Map<String,Object> criteria) throws PersistenceException {
          logger.debug("enter - count(Class,Map)");
          if( logger.isDebugEnabled() ) {
              logger.debug("For: " + cache.getTarget().getName() + "/" + cls + "/" + criteria);
          }
          try {
              Transaction xaction = Transaction.getInstance(true);
              
              try {
                  long count = 0L;
      
                  criteria = xaction.execute(cls, criteria);
                  count = ((Number)criteria.get("count")).longValue();
                  xaction.commit();
                  return count;
              }
              finally {
                  xaction.rollback();
              }
          }
          finally {
              logger.debug("exit - count(Class,Map)");
          }
      }
docs: Counts the number of items matching an arbitrary query. This method expects the passed in
  query to have one field called 'count' in the map it returns. Anything else is ignored
  @param cls the execution class for the arbitrary query
  @param criteria the criteria to match against for the query
  @return the number of matches (essentially, the number returned from the arbitrary query in the 'count' field)
  @throws PersistenceException an error occurred executing the query.