@Override
    @SuppressWarnings({"unchecked", "rawtypes"})
    public <T> Stream<T> stream(Query query, @Nullable FactoryExpression<?> projection) {
        final Stream resultStream = query.getResultStream();
        if (projection != null) {
            return resultStream.map(element -> projection.newInstance((Object[]) (element.getClass().isArray() ? element : new Object[] {element})));
        }
        return resultStream;
    }
{@code HibernateHandler} is the {@link QueryHandler} implementation for Hibernate

@author tiwe
querydsl-jpa/src/main/java/com/querydsl/jpa/HibernateHandler.java