setMaxResults/offset generates illegal SQL for DB2 mainframe

Description

the fix for works for DB2 LUW (Linux/Unix/Windows) but does not work on DB2 for z/OS.

Specifically order of is not supported inside over():

select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( ...

I worked around this issue by extending the DB2 dialect and changing the above SQL to:

select * from ( select inner2_.*, rownumber() over(order by inner2_.SORT_COLUMN_ALIAS_HERE) as rownumber_ from ( ...

or for cases when the subquery isn't ordered:

select * from ( select inner2_.*, rownumber() over() as rownumber_ from ( ...

Which works for DB2 LUW and DB2 for z/OS.

I could provide a pull request, but to do this I had to parse the original SQL. Is the Hibernate team interested in a pull request if the dialect has to parse SQL?

Attachments

1

Activity

Show:

Victoria Sexmero March 23, 2016 at 7:34 PM

No se qué hacer con la clase que anexas. ¿Qué hago para que mi proyecto funcione correctamente?

Brad Cupit November 6, 2015 at 3:45 AM

Original bug reporter here. Unfortunately I no longer work with the company I wrote this code for, and I don't have access to it. Nor do I have access to DB2 on the mainframe.

However, I have written the tech lead of that project to see if he'd like to get the changes into Hibernate proper.

Steve Ebersole October 30, 2015 at 2:29 PM

Lots of Dialects parse SQL in order to do stuff. It's not ideal, but given the design of how Hibernate generates SQL at the moment there really is not another option.

Steve Ebersole October 30, 2015 at 2:27 PM

But that is exactly my concern. So many of these Dialects are "dump and run" style of OSS. No one "owns" them in an ongoing sense. In fact this is something we take into consideration nowadays in terms of deciding to accept new Dialects.

Christian Beikov October 30, 2015 at 9:20 AM

@Steve Ebersole I guess this issue is still relevant since the dialect hasn't been fixed in any way nor a new dialect was added. The proposed dialect implementation has room for improvement but generally looks ok.

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created January 26, 2012 at 11:01 PM
Updated March 23, 2016 at 7:34 PM