-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Added parenthesis to "order by" of generated SQL p
PostPosted: Wed Sep 06, 2006 12:09 pm 
Newbie

Joined: Wed Sep 06, 2006 11:19 am
Posts: 1
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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 12:29 pm 
Newbie

Joined: Wed Feb 07, 2007 12:22 pm
Posts: 1
Hello.

I'm struck with exactly same problem. :(
[SQL0104] Token , was not valid. Valid tokens: )

I looked at DB2Dialect source. Looks like parenthesis in order by is not generated from there. Should be in UserType.

Did anyone resolve this or have a work around?

Any pointer is most appreciated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.