@Override
    public long fetchCount() {
        try {
            Query query = createQuery(true);
            query.setUnique(true);
            Long rv = (Long) execute(query, true);
            if (rv != null) {
                return rv;
            } else {
                throw new QueryException("Query returned null");
            }
        } finally {
            reset();
        }

    }
Close the query and related resources
querydsl-jdo/src/main/java/com/querydsl/jdo/AbstractJDOQuery.java