-->
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.  [ 7 posts ] 
Author Message
 Post subject: Subquery in the FROM clause with HQL
PostPosted: Mon Feb 25, 2008 8:34 am 
Newbie

Joined: Tue Dec 04, 2007 6:48 am
Posts: 5
Location: Spain
Hi all,
Are this kind of queries supported by HQL?

SELECT COUNT(*)
FROM (
SELECT a, b, c, SUM(d)
FROM T1, T2, ...
WHERE ...
GROUP BY a, b, c
)

I am looking for an efficient way to count the results of my query, without having to say Hibernate to retrieve all the resulting rows.


Thanks in advance :-)

Rubén


Top
 Profile  
 
 Post subject: have solution yet?
PostPosted: Wed Feb 27, 2008 6:10 am 
Newbie

Joined: Thu Dec 06, 2007 10:07 pm
Posts: 4
I'm also looking for such example, have you found any solution yet? Or anyone colud help on this?
Many thanks!


Top
 Profile  
 
 Post subject: No answers still
PostPosted: Wed Feb 27, 2008 5:25 pm 
Newbie

Joined: Tue Dec 04, 2007 6:48 am
Posts: 5
Location: Spain
Hi,
I still don't have an answer for this... So I had to do a new query for counting results

I hope you'll have more luck than me...


Top
 Profile  
 
 Post subject: No answers still
PostPosted: Wed Feb 27, 2008 5:26 pm 
Newbie

Joined: Tue Dec 04, 2007 6:48 am
Posts: 5
Location: Spain
Sorry, I clicked "submit" too many times...


Last edited by rdopico on Wed Feb 27, 2008 5:29 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: No answers still
PostPosted: Wed Feb 27, 2008 5:27 pm 
Newbie

Joined: Tue Dec 04, 2007 6:48 am
Posts: 5
Location: Spain
Hi,
I still don't have an answer for this... So I had to do a new query for counting results

I hope you'll have more luck than me...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 4:39 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
NO.
HQL subqueries may occur only in the select or where clauses.
So, we cannot have inline views ( subquery in from clause) in HQL.
Try using createSQLQuery instead.

---------------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 11:11 am 
Newbie

Joined: Thu Dec 06, 2007 10:07 pm
Posts: 4
Hi,
I do my query by using native sql query and try to avoid using non-standard (which is ANSI SQL 92) statments and got my resultset.

by the way, why doesn't HQL provide a aggregate function -- stdev just like avg(), max() min() etc...?


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