it sounds reasonable to me
On 7 June 2016 at 10:57, Vlad Mihalcea <mihalcea.vlad(a)gmail.com> wrote:
To get a picture of why we need this, consider the following example
from
the docs:
Stream<Object[]> persons = session.createQuery(
"select p " +
"from Person p " +
"where p.name like :name" )
.setParameter( "name", "J%" )
.stream();
Map<Phone, List<Call>> callRegistry = persons
.map( row -> Person.class.cast( row[0] ) )
.flatMap( person -> person.getPhones().stream() )
.flatMap( phone -> phone.getCalls().stream() )
.collect(Collectors.groupingBy(Call::getPhone));
The .map( row -> Person.class.cast( row[0] ) ) call should be avoided and
we should return a Stream<Person> in this case.
Vlad
On Tue, Jun 7, 2016 at 12:50 PM, Vlad Mihalcea <mihalcea.vlad(a)gmail.com>
wrote:
> Hi,
>
> While writing documentation for the new 5.2 Query.stream() API, I
realized
> that we don't return a Stream<T>, but a Stream<Object[]> which
could
> confuse users.
> This is because ScrollableResultsImpl does something like this:
>
> if ( result != null && result.getClass().isArray() ) {
> currentRow = (Object[]) result;
> }
> else {
> currentRow = new Object[] {result};
> }
>
> The result is the actual entity that we queries, while the currentRow is
an Object[].
>
> I think we might want to change the stream result so that we return the
result for each available entry.
>
> Vlad
>
_______________________________________________
hibernate-dev mailing list
hibernate-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev