• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Row counts with Hibernate Criteria

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
For our searching page, we are using Hibernate Criteria class to build the query at runtime.
The result page should employ Hibernate pagination facilities.
I have no problems running the query and getting the 50 record from the database, but how to get the whole number of matching records?
Thanks.
 
jim li
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to use "Restrictions"

like: c.add( Restrictions.like( "firstName", "%" + filterValue + "%" )).setProjection(Projections.rowCount())
[ July 02, 2008: Message edited by: jim li ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, you just want the count? Like the total number of records returned?

I guess you could simply do the query and ask the list for its size: list.size();

-Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic