Skip to content

Commit

Permalink
fix use of raw types in AbstractSelectionQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Jan 17, 2025
1 parent 9677aba commit a9ea918
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public interface ScrollableResults<R> extends AutoCloseable {
*/
void close();

/**
* @return {@code true} if {@link #close()} was already called
*/
boolean isClosed();

/**
* Advance to the next result.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package org.hibernate.query.internal;

import org.hibernate.Incubating;
import org.hibernate.ScrollableResults;
import org.hibernate.query.spi.CloseableIterator;
import org.hibernate.query.spi.ScrollableResultsImplementor;

/**
* @author Steve Ebersole
Expand All @@ -15,9 +15,9 @@
*/
@Incubating
public class ScrollableResultsIterator<T> implements CloseableIterator<T> {
private final ScrollableResultsImplementor<T> scrollableResults;
private final ScrollableResults<T> scrollableResults;

public ScrollableResultsIterator(ScrollableResultsImplementor<T> scrollableResults) {
public ScrollableResultsIterator(ScrollableResults<T> scrollableResults) {
this.scrollableResults = scrollableResults;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.ScrollableResults;
import org.hibernate.query.QueryFlushMode;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
Expand Down Expand Up @@ -251,15 +252,12 @@ public Stream<R> getResultStream() {
return stream();
}

@SuppressWarnings( {"unchecked", "rawtypes"} )
@Override
public Stream stream() {
final ScrollableResultsImplementor scrollableResults = scroll( ScrollMode.FORWARD_ONLY );
final ScrollableResultsIterator iterator = new ScrollableResultsIterator<>( scrollableResults );
final Spliterator spliterator = spliteratorUnknownSize( iterator, Spliterator.NONNULL );

final Stream stream = StreamSupport.stream( spliterator, false );
return (Stream) stream.onClose( scrollableResults::close );
public Stream<R> stream() {
final ScrollableResults<R> results = scroll( ScrollMode.FORWARD_ONLY );
final Spliterator<R> spliterator =
spliteratorUnknownSize( new ScrollableResultsIterator<>( results ), Spliterator.NONNULL );
return StreamSupport.stream( spliterator, false ).onClose( results::close );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
*/
@Incubating
public interface ScrollableResultsImplementor<R> extends ScrollableResults<R> {
boolean isClosed();
}

0 comments on commit a9ea918

Please sign in to comment.