-->
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.  [ 2 posts ] 
Author Message
 Post subject: criteria + count
PostPosted: Wed Sep 20, 2006 4:11 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 3:37 am
Posts: 29
Hi,

I'm looking for the way to return the number of element of a criteria query

here is a normal query I use I want to have the same parameter but I only want the number of element

Code:
List<Criterion> criterions = new ArrayList<Criterion>();      
criterions.add(Property.forName("id.marketId").eq(marketId));
Criterion myExpressionModel = Expression.like("modelId", filterModel, MatchMode.ANYWHERE).ignoreCase();
Criterion myExpressionChassis = Expression.like("chassis", filterChassis, MatchMode.ANYWHERE).ignoreCase();
criterions.add(myExpressionModel);
criterions.add(myExpressionChassis);
List<ProductDb> products = this.productDbDao.findByCriterions(criterions, refPos, refSize);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 7:09 am 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
use:

criteria.setProjection(Projections.rowCount());

and criteria.uniqueResult() returns a java.lang.Integer containing number of rows.

-----------------

don't forget to credit

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


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