-->
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.  [ 1 post ] 
Author Message
 Post subject: db2 dialect paging sorting subquery
PostPosted: Mon Dec 01, 2008 4:53 am 
Newbie

Joined: Mon Dec 01, 2008 4:29 am
Posts: 1
Hi,
I'm currently facing problem with db2 dialect. I'm trying to order by subquery with paging activated as well.
Example:

select a.id ,
(select count( aig ) from AgentInGroup aig where aig.agentGroup =a ) as
agentAlias
from Agent a
order by col_1_0_

which generates sql:
select
*
from
( select
rownumber() over(
order by
col_1_0_) as rownumber_,
agent0_.SLA_ID as col_0_0_,
(select
count(agentingro1_.SLAGM_ID)
from
SL_AGENT_IN_GROUP agentingro1_,
SL_AGENT_GROUP agentgroup2_
where
agentingro1_.SLAG_ID=agentgroup2_.SLAG_ID
and agentingro1_.SLAG_ID=agent0_.SLA_ID) as col_1_0_
from
SL_AGENT agent0_
order by
col_1_0_ ) as temp_
where
rownumber_ between ?+1 and ?

This however is producing SQLGrammarException.
I've used col_1_0_ in hql in porpose couse aliases aren't working with subqueries. I tried with numbers of columns instead of aliases but ordering wasn't right in that case.
What is the solutions for sorting over subqueries, anyone???

hibernate version 3.3.1.GA


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

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.