@Override
    public QueryResults<T> fetchResults() {
        // TODO : handle entity projections as well
        try {
            Query countQuery = createQuery(true);
            long total = ((Number) countQuery.getSingleResult()).longValue();
            if (total > 0) {
                QueryModifiers modifiers = queryMixin.getMetadata().getModifiers();
                Query query = createQuery(false);
                @SuppressWarnings("unchecked")
                List<T> list = (List<T>) getResultList(query);
                return new QueryResults<T>(list, modifiers, total);
            } else {
                return QueryResults.emptyResults();
            }
        } finally {
            reset();
        }

    }
Transforms results using FactoryExpression if ResultTransformer can't be used

@param query query
@return single result
querydsl-jpa/src/main/java/com/querydsl/jpa/sql/AbstractJPASQLQuery.java