I think we all agree that this should be limited-to/backed-by ScrollableResults. As far as a dedicated #stream() method, the only real benefit I see is to more generically define the return type from #scroll(). So ScrollableResults would be a Stream, #scroll() would simply call #stream(). As far as the rest you bring up (Speedment, lambda expressions, etc) I'd personally think that is better implemented as an extension of the Hibernate Session#createFilter() capability if we were to fully materialize support for that. #createFilter() currently focuses on persistent collections. We would need to also allow streaming from an entity as well:
Optional<Event> event = session.stream( Event.class )
.filter(e -> e.getTitle == "Java 8")
.findFirst();
Optional<Event> event = session.stream( myEntity.getEvents(), Event.class )
.filter(e -> e.getTitle == "Java 8")
.findFirst();
|