-->
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: count objects?
PostPosted: Mon Aug 01, 2005 8:05 am 
Hi, is there any count() function in HQL that I can use to get a count of how many objects exist in the database?

In my case I need to get a count of all objects with a certain StatusId, something like

Code:
(?)count(?) resources from Resources as resources where resources.StatusId = 2


Obviously the syntax above is not correct, does anybody know the right way to do this? I could just select all the objects and return a count of them, but this seems like a waste when all I want to do is find out how many exist.


Top
  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 10:18 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Try

Code:
select count(r) from Resources r where r.StatusId = 2


Read more here:
11.5. Aggregate functions

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject: thanks!
PostPosted: Mon Aug 01, 2005 3:53 pm 
Thanks for the reply, that helps! :)


Top
  
 
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.