[hibernate-dev] ScrollableResults and 6.0

Steve Ebersole steve at hibernate.org
Tue Jan 3 09:45:54 EST 2017


Inline...

On Tue, Jan 3, 2017 at 5:39 AM Gunnar Morling <gunnar at hibernate.org> wrote:

> 2017-01-03 11:57 GMT+01:00 Sanne Grinovero <sanne at hibernate.org>:
>


> Btw. we'd one Tuple type per number of returns, i.e. Tuple2, Tuple3 etc.,
> each with the right number of type arguments. As said I'm not fully
> convinced myself, but some may find it nicer to use than casting the
> elements of an array.
>

That is not how Tuple works in list()/uniqueResult() even.

Look, ultimately all I am proposing here is to make Query#scroll work the
same as, e.g., Query#list in terms of its return signature.

For Query<Tuple>#list you do not get back multiple Tuple objects (per
"row").  Why would you here?

Perhaps y'all are getting hung up on the name Tuple.  Tuple represents the
entire row, each "column" in that row.  E.g.

List<Tuple> results = session.createQuery( "select e.prop1 as p1, e.prop2
as p2 from Entity e", Tuple.class ).list();

for ( Tuple tuple : results ) {
    // access "prop1":
    tuple.get(0)
    tuple.get("p1")
    ...
    // access "prop2":
    tuple.get(1)
    tuple.get("p2")
    ...
}

Tuple is really just a "nicer" (ymmv) way to deal with Object[]...


More information about the hibernate-dev mailing list