-->
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: Parameterised order by direction
PostPosted: Tue Jul 04, 2006 12:48 pm 
Newbie

Joined: Tue Jul 04, 2006 12:09 pm
Posts: 2
Hi,

I'm trying to do the following with HQL:

<query name="findCurrentCompanies">
<![CDATA[
select distinct(company) from Company company
order by company.longName :arg_0
]]>
</query>

Where :arg_0 is a parameter representing sort direction e.g. asc or desc.

Running this gives:

org.hibernate.hql.ast.QuerySyntaxException: unexpected token

I believe parameters can be used in the order by clause; am I to assume that they cannot be used for the sort direction.

Thanks in advance,

Martin.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 1:22 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yes, they can't be used that way, because named parameters are converted to SQL positional parameters, and they can't be used for order direction. You'll have to have multiple named queries (one for each order combination you need), or switch to Criteria.

_________________
Code tags are your friend. Know them and use them.


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.