-->
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: Row count with Criteria
PostPosted: Mon Sep 17, 2007 10:16 am 
Newbie

Joined: Thu Sep 13, 2007 4:00 pm
Posts: 11
Hi all,
I'm using Criteria and I want to retrieve the total number of records without actually return the data. How do I do that? I've already seen Projections but I didn't find any example of usage

_________________
André Rodrigues Pena


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 1:29 pm 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
criteria.setProjection(Projections.rowCount());
int count = (Integer) critera.uniqueResult() ;

Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 25, 2007 3:31 pm 
Newbie

Joined: Tue Sep 18, 2007 11:13 am
Posts: 8
with Scrollable results u can instatiate a cursor to the resultset,
then set the cursorr to point to last record cursor.last()
and get the row number by cursor.getRowNumber().
the returned value is the total number of rows returned.

Anybody having a better idea pls mail me.


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.