Good idea. So, ResultTranformer will extend both the ResultRowTransformer and ResultListTransformer so it will inherit both methods.
Actually, the `transformList(List list)` is only needed by `DistinctResultTransformer`, so most of the time we'd only have to pass `ResultRowTransformer`. Vlad On Tue, Mar 1, 2016 at 1:55 PM, Gunnar Morling <gun...@hibernate.org> wrote: > Hi, > > Tinkering with result transformers, I wished I'd be able to express a > tuple transformation like this, using Java 8 Lambda-style: > > session.createQuery( "SELECT foo, bar FROM Baz" ) > .transformResultTuples( (tuple, aliases) -> { return tuple[0] > + " " + tuple[1]; } ) > .list(); > > That requires an interface with a single abstract method ("functional > interface") describing the Lambda type. The current ResultTransformer > interface has two methods, so it cannot be used as is. > > I thus propose to deprecate ResultTransformer and add two new, > separate contracts: ResultRowTransformer and ResultListTransformer. > Query#setResultTransformer() would be superseded by two new methods: > transformResultTuples() and transformResultList(). > > Note that this change is fully compatible with previous Java versions: > One still can pass an (anonymous) implementation of the contracts when > stuck to Java 6/7. That backwards-compatible design is a really nice > trait of how Lambdas have been added to the Java language. > > Lambda-friendliness is something which I think we should generally > keep in mind when designing new APIs. Maybe there also other ones > existing, that'd benefit from retrofitting. > > Any thoughts? > > Thanks, > > --Gunnar > _______________________________________________ > 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