-->
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.  [ 4 posts ] 
Author Message
 Post subject: why does not work: select count(*) from (complex subquery)
PostPosted: Fri Apr 02, 2004 11:21 am 
Newbie

Joined: Fri Apr 02, 2004 9:57 am
Posts: 14
How should I express the following SQL query with HQL?

select count(*) from (complex subquery)

Thanks,
Norbi


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 1:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Subqueries are not allowed on the from clause AFAIK

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 2:11 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It is possible to use views for this use case (not all of RDBMS implementations support inline views too)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 2:46 pm 
Newbie

Joined: Fri Oct 31, 2003 9:17 am
Posts: 10
Location: USA
MS SQL Server 2000(+), and Oracle 9i(+) currently support subqueries in the from clause. (MySQL will have this soon).

If you are just looking for a straight count, you could:
1. Grab the Connection from the Session and do it the old fashioned way.
2. Check out http://www.hibernate.org/118.html#A3

I'm sure there are other alternatives, but these work for me.

hope this helps


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