This question is an extension of Unable to fetch result set in Batches using ScrollableResults.
I have defined a custom dialect .
public class MyPostgreSQL