@Override
    public long fetchCount() {
        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");
        }
    }
Close the query and related resources
querydsl-jdo/src/main/java/com/querydsl/jdo/sql/AbstractSQLQuery.java