So long as we limit that to the Stream access, +1
On Tue, Jun 7, 2016 at 5:07 AM andrea boriero wrote:
> it sounds reasonable to me
>
> On 7 June 2016 at 10:57, Vlad Mihalcea wrote:
>
> > To get a picture of why we need this, consider the following example from
> > the docs:
> >
> > Stream
it sounds reasonable to me
On 7 June 2016 at 10:57, Vlad Mihalcea wrote:
> To get a picture of why we need this, consider the following example from
> the docs:
>
> Stream persons = session.createQuery(
>"select p " +
>"from Person p " +
>"where p.name like :name" )
> .setParameter( "name", "J%" )
> .stream();
>
> Map 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 in this case.
>
> Vlad
>
> On Tue, Jun 7, 2016 at 12:50 PM, Vlad Mihalcea
> wrote:
>
> > Hi,
> >
> > While writing documentation for the new 5.2 Query.stream() API, I
> realized
> > that we don't return a Stream, but a Stream 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@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev
To get a picture of why we need this, consider the following example from
the docs:
Stream persons = session.createQuery(
"select p " +
"from Person p " +
"where p.name like :name" )
.setParameter( "name", "J%" )
.stream();
Map 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 in this case.
Vlad
On Tue, Jun 7, 2016 at 12:50 PM, Vlad Mihalcea
wrote:
> Hi,
>
> While writing documentation for the new 5.2 Query.stream() API, I realized
> that we don't return a Stream, but a Stream 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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev