Solution of Hibernate paging report only entering result set and not supporting requested operation

I checked the information on the Internet. The reason is that when pagination is used, the query result is empty, but pagination is also set, so an error will be reported.

There are two solutions:

Scheme 1, add conditions under paging code

public static List<?> getList(Session session , String HQL , int currentPage, int pageSize){
		Query q = session.createQuery(HQL);
		if(currentPage != 0 && pageSize != 0 && q.list().size()!= 0)
		{
		    int startRow = (currentPage-1)*pageSize;
		    q.setFirstResult(startRow);
		    q.setMaxResults(pageSize);
		}
	    List<?> list = q.list();
	    //Return search results
	    return list;
	 } 

The if condition is that when the query result is empty, there will be no pagination, so no error will be reported.

Scheme 2: add this sentence to the hibernate configuration file

<property name="jdbc.use_scrollable_resultset">false</property>

Read More: