-->
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.  [ 3 posts ] 
Author Message
 Post subject: Need help on complex Subquery with Aggregate functions
PostPosted: Wed Nov 05, 2003 6:55 pm 
Newbie

Joined: Wed Nov 05, 2003 6:49 pm
Posts: 2
Hey guys, I am trying to execute the following query and get a

Code:
net.sf.hibernate.QueryException: in expected: select [select e.cert ....


Now the query is pretty beefed up, but we want to see if you can run this kind of subquery through Hibernate.

Code:
select e.certSerNbr, e.psdVendId, e.psdModId, e.psdSerNbr, e.dupErrCode, e.postgType, e.mailType, e.POSTAGE, e.COUNT, first.orgnScanFclt, e.MINTIME, recent.orgnScanFclt, e.MAXTIME
from
(select es.certSerNbr, es.psdVendId, es.psdModId, es.psdSerNbr, es.postgType, es.mailType, count(es.mailpieceId) as COUNT, es.postVal as POSTAGE, min(es.orgnScanTime) as MINTIME, max(es.orgnScanTime) as MAXTIME from ExceptionSum es where es.dupErrCode = 'D' and es.dupErrCode not like '%O%' group by es.certSerNbr, es.psdVendId, es.psdModId, es.psdSerNbr, es.postgType, es.postgVal, es.mailType) e,
ExceptionSum first, ExceptionSum recent
where e.orgnScanTime between :dateFrom and :dateTo and e.dupErrCode = 'D' and e.dupErrCode not like '%O%' and first.certSerNbr = e.certSerNbr and first.psdVendId = e.psdVendId and first.psdModId = e.psdModId and first.psdSerId = e.psdSerId and e.MINTIME = first.orgnScanTime and recent.certSerNbr = e.certSerNbr and recent.psdVendId = e.psdVendId and recent.psdModId = e.psdModId and recent.psdSerId = e.psdSerId and e.MAXTIME = recent.orgnScanTime


can hibernate handle something like this? we have been looking through the query over and over again for possible syntax errors, but we don't know why we are getting this exception.

thanks, erica


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2003 7:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
HQL does not support FROM-clause subqueries (WHERE-clause subqueries only).

Since your query is not returning objects and is not really at all object-oriented, I think direct JDBC would work just fine for this :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2003 10:13 am 
Newbie

Joined: Wed Nov 05, 2003 6:49 pm
Posts: 2
thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.