I found the solution with "hibernate.legacy_limit_handler = true" for DB2390Dialect some time ago, and got rid of the exception. But I now have a new problem.
For example, suppose the table MYTABLE contains the following rows (column "client" is primary key):
Code:
client description
----------------------------
A a description for A
B a description for B
C a description for C
When I set "TypedQuery.setMaxResults(
2)", both Hibernate 4.3.11 and Hibernate 5.2.10 generate the following SQL queries with "TypedQuery.getResultList()":
First call:
Code:
select
myclient0_.client as client1_0_,
myclient0_.description as descript2_0_
from
MYTABLE scmsclient0_ fetch first 2 rows only
Second call:
Code:
select
myclient0_.client as client1_0_,
myclient0_.description as descript2_0_,
from
MYTABLE scmsclient0_ fetch first 4 rows only
As expected, Hibernate 4 returns "(A, B)" on the first call and "(C)" on the second call.
Hibernate 5 returns "(A, B)" with
every call, i.e.
always the two first rows.