@SuppressWarnings("unchecked")
    @Override
    public QueryResults<T> fetchResults() {
        parentContext = startContext(connection(), queryMixin.getMetadata());
        Expression<T> expr = (Expression<T>) queryMixin.getMetadata().getProjection();
        QueryModifiers originalModifiers = queryMixin.getMetadata().getModifiers();
        try {
            if (configuration.getTemplates().isCountViaAnalytics()
                && queryMixin.getMetadata().getGroupBy().isEmpty()) {
                List<T> results;
                try {
                    queryMixin.addFlag(rowCountFlag);
                    getLastCell = true;
                    results = fetch();
                } finally {
                    queryMixin.removeFlag(rowCountFlag);
                }
                long total;
                if (!results.isEmpty()) {
                    if (lastCell instanceof Number) {
                        total = ((Number) lastCell).longValue();
                    } else {
                        throw new IllegalStateException("Unsupported lastCell instance " + lastCell);
                    }
                } else {
                    total = fetchCount();
                }
                return new QueryResults<T>(results, originalModifiers, total);

            } else {
                queryMixin.setProjection(expr);
                long total = fetchCount();
                if (total > 0) {
                    return new QueryResults<T>(fetch(), originalModifiers, total);
                } else {
                    return QueryResults.emptyResults();
                }
            }

        } finally {
            endContext(parentContext);
            reset();
            getLastCell = false;
            parentContext = null;
        }
    }
Get the results as a JDBC ResultSet

@return results as ResultSet
querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java