File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes How criteria working for Criteria.setMaxResults(10) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "How criteria working for Criteria.setMaxResults(10)" Watch "How criteria working for Criteria.setMaxResults(10)" New topic
Author

How criteria working for Criteria.setMaxResults(10)

Rajan Nath
Greenhorn

Joined: Nov 27, 2007
Posts: 22
I am using criteria, for pagination. The application get slow as for every page it brings all the records although (through display tag) only 10 records displayed.
when I used Criteria.setMaxResults(10), it brings only 10 records, I want to know is Hibernated firing query to bring only 10 records from database.
I am not able to see in any thing related with that in generated HQL.

Thanks
Raj
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4967

If you add the following to your hibernate.cfg.xml file, you should be able to see the sql being generated:




This will also provide more debug information and variables being used for the insertion in your code. This is a log4j setting for Hibernate:



Let us know what you see!

-Cameron McKenzie


Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
Rajan Nath
Greenhorn

Joined: Nov 27, 2007
Posts: 22
Thanks Cameron,
I am using the show_sql . The query generated I am able to find out but the query is not contains any thing due to which only 10 records fetched.
Can any body send how exactly the sample query will generate by using setMaxResult
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How criteria working for Criteria.setMaxResults(10)
 
Similar Threads
find method from database side in B&S
Criteria
Hibernate Scrolling Results
Confuse the findByCriteria()
Help on Displaying Query Result in JTable