After I upgrade hibernate in my application from 5.2.6 to 5.4.2 without modify any line of code. I got below exception.
java.lang.ClassCastException: com.sun.proxy.$Proxy846 cannot be cast to [Ljava.lang.Object;
java.util.Iterator.forEachRemaining(Iterator.java:116)
java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
From investigation found that, the exception occur in ScrollableResultsIterator.java class in hibernate lib itself. The exception occur on result is casting on result returning as below.
@Override@Override @SuppressWarnings("unchecked")
public T next() {
Object[] next = scrollableResults.get();
if ( next.length == 1 ) {
return (T) next[0]; <<<===== Exception here
} else {
return (T) next;
}
}
|