I’m upgrading code that worked in Hibernate 5 to hibernate 6, and found that one of our queries results in an infinitely looping call - locking up the SQL table.
The querystring contains a “fetch” keyword, and we use query.Scroll() to get a scrollableResults (allegedly for performance purposes?) - we then immediately call scrollableResults.last() - which never completes nor crashes.
By calling query.list() I was able to determine that the result list is empty (which is expected in this case)
I debugged the FetchingScrollableResultsImpl.last() call, and saw that it loops infinitely within these lines:
while ( !afterLast ) {
more = next();
}
Curiously, a few lines before this there’s a check for ‘isResultSetEmpty()’ that returns true, despite the previously mentioned query.list() showing there are no results.
I’ve tried this on 6.4.0 and 6.5.0, same issue.