Search in sources :

Example 1 with ScrollableResultsIterator

use of org.hibernate.query.internal.ScrollableResultsIterator in project hibernate-orm by hibernate.

the class AbstractSelectionQuery method stream.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Stream stream() {
    final ScrollableResultsImplementor scrollableResults = scroll(ScrollMode.FORWARD_ONLY);
    final ScrollableResultsIterator iterator = new ScrollableResultsIterator<>(scrollableResults);
    final Spliterator spliterator = Spliterators.spliteratorUnknownSize(iterator, Spliterator.NONNULL);
    final Stream stream = StreamSupport.stream(spliterator, false);
    return (Stream) stream.onClose(scrollableResults::close);
}
Also used : ScrollableResultsIterator(org.hibernate.query.internal.ScrollableResultsIterator) Stream(java.util.stream.Stream) Spliterator(java.util.Spliterator)

Aggregations

Spliterator (java.util.Spliterator)1 Stream (java.util.stream.Stream)1 ScrollableResultsIterator (org.hibernate.query.internal.ScrollableResultsIterator)1