-->
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: how to get the count of result
PostPosted: Thu Sep 04, 2003 9:10 pm 
Newbie

Joined: Tue Sep 02, 2003 10:28 pm
Posts: 11
className: Cat.java
query: "from Cat cat where cat.id > 5"


Query q = session.createQuery(queryString);
q = q.setString(query);
List list = q.list();

i can get the count by list.size()

but this will reduce the peformance some big

How can i get the result count without list all the items?

just like taking this sql: select count(id) from CAT where id>5; in jdbc?

please help me, thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 9:52 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Hibernate Users FAQ - Tips & Tricks
It's the first question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 10:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Also, just to clarify:
Quote:
but this will reduce the peformance some big


You've already called list() on the query which preloads the results. So calling list.size() at that point is not that big of a deal.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 11:09 pm 
Newbie

Joined: Tue Sep 02, 2003 10:28 pm
Posts: 11
thank you very much


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.