Hi ,
Am new to Hibernate and currently working on a service which connects to DB2 Z/os version 11.
The service is using JPA repositories and ORM model to pull data from DB2. The ORM model has associations and relationships defined in them.
Upon trying to send a pageable object in the JPA Repository and trying to query for say - pagenumber =2 and pagesize = 1 , I am getting the following error :-
ILLEGAL USE OF KEYWORD OF. TOKEN ??( [ DESC ASC NULLS RANGE CONCAT || / MICROSECONDS MICROSECOND WAS EXPECTED. SQLCODE=-199, SQLSTATE=42601, DRIVER=4.19.26Upon checking the logs could find that hibernate is creating the below query for pagination to select the second page for employee details from EMPLOYEE table with paging size parameter as 1:-
select * from
( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_
from
( select id as id_,name as name_ from employee as employee_ where employee_.name="employee1" order by employee_.id fetch first 2 rows only )
as inner2_)
as inner1_ where rownumber_ > 1 order by rownumber_;If I take the query created by hibernate and execute in DB2 , I receive the same error.
This is because of using ORDER BY ORDER OF <tablename> clause inside an OLAP function like ROW_NUMBER() OVER .
According to IBM, this is not allowed :-
https://www.ibm.com/support/knowledgece ... lause.html"For an ORDER BY clause in an OLAP specification, table-designator must not specify a table function, a materialized view, a nested table expression that is materialized, an alias, or a synonym"
My question is why is Hibernate trying to create a query which is not allowed by IBM . Is there any way I can force Hibernate to create the right query without NamedQuery ?
Regards,
Abhishek