@Nullable
    @SuppressWarnings("unchecked")
    @Override
    public T fetchOne() throws NonUniqueResultException {
        try {
            Query query = createQuery(getMetadata().getModifiers(), false);
            return (T) getSingleResult(query);
        } catch (javax.persistence.NoResultException e) {
            logger.log(Level.FINEST, e.getMessage(), e);
            return null;
        } catch (javax.persistence.NonUniqueResultException e) {
            throw new NonUniqueResultException(e);
        } finally {
            reset();
        }
    }
{@inheritDoc}

@deprecated {@code fetchResults} requires a count query to be computed. In {@code querydsl-sql}, this is done
by wrapping the query in a subquery, like so: {@code SELECT COUNT(*) FROM (&lt;original query&gt;)}. Unfortunately,
JPQL - the query language of JPA - does not allow queries to project from subqueries. As a result there isn't a
universal way to express count queries in JPQL. Historically QueryDSL attempts at producing a modified query
to compute the number of results instead.

However, this approach only works for simple queries. Specifically
queries with multiple group by clauses and queries with a having clause turn out to be problematic. This is because
{@code COUNT(DISTINCT a, b, c)}, while valid SQL in most dialects, is not valid JPQL. Furthermore, a having
clause may refer select elements or aggregate functions and therefore cannot be emulated by moving the predicate
to the where clause instead.

In order to support {@code fetchResults} for queries with multiple group by elements or a having clause, we
generate the count in memory instead. This means that the method simply falls back to returning the size of
{@link #fetch()}. For large result sets this may come at a severe performance penalty.

For very specific domain models where {@link #fetchResults()} has to be used in conjunction with complex queries
containing multiple group by elements and/or a having clause, we recommend using the
<a href="https://persistence.blazebit.com/documentation/1.5/core/manual/en_US/index.html#querydsl-integration">Blaze-Persistence</a>
integration for QueryDSL. Among other advanced query features, Blaze-Persistence makes it possible to select
from subqueries in JPQL. As a result the {@code BlazeJPAQuery} provided with the integration, implements
{@code fetchResults} properly and always executes a proper count query.

Mind that for any scenario where the count is not strictly needed separately, we recommend to use {@link #fetch()}
instead.
querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java