Hi,
I have a problem with added parenthesis to the "order by" clause of the SQL generated from HQL. The database is a DB2 on an iSeries5 running OS400, with WAS 5.1 and the JTOpen JDBC driver. I've tried both the DB2 and the DB2400 dialects, and both yield the same result.
I use a UserType to map two columns, having a slightly freakish format, to a Calendar object, which works just fine. However, when trying to use "order by" in the HQL on this object, the problem arises. The HQL sentence looks like this:
Code:
from Sak sak where sak.kreditor = ? and sak.sakstype = 2 order by sak.dato
The SQL generated from this is:
Code:
select sak0_.BGAJCD as BGAJCD, sak0_.BGB2CD as BGB2_0_, sak0_.BGABCD as BGABCD0_, sak0_.BGKYTX as BGKYTX0_, sak0_.BGJBCD as BGJBCD0_, sak0_.BGKZTX as BGKZTX0_, sak0_.BGATDT as BGATDT0_, sak0_.BGACST as BGACST0_, sak0_.BGKXTX as BGKXTX0_, sak0_.BGOMVA as BGOMVA0_, sak0_.BGONVA as BGONVA0_, sak0_.BGOOVA as BGOOVA0_, sak0_.BGOPVA as BGOPVA0_, sak0_.BGHSST as BGHSST0_, sak0_.BGK0TX as BGK15_0_, sak0_.BGEMDT as BGEMDT0_, sak0_.BGAGTM as BGAGTM0_ from IKBGCPL1 sak0_ where sak0_.BGABCD=002030 and sak0_.BGHSST=2 order by (sak0_.BGEMDT, sak0_.BGAGTM)
Now, this SQL is semantically correct, but notice the parenthesis added around "sak0_.BGEMDT, sak0_.BGAGTM" at the very end. They produce a
Code:
SQL Error: -104, SQLState: 42601
[SQL0104] Token , was not valid. Valid tokens: ).
So, basically it can't handle the comma inside the parenthesis. If I remove the parenthesis and run the SQL through a client, everything's hunkydory.
Is this possible to solve by modifying the dialect file, or does it go deeper than that? I've not seen anyone filing an issue on this before, so should I do this?