• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Want clarification for some of the methods of Criteria class of org.hibernate

Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

SQL has following kind of syntax:

select * from table_name limit 1,10;

where table_name is any table of database:

it fetches only first 10 records.

i am using criteria queries for querying database. for above operation i have found out following 3 methods.

1) setFirstResult(int i)
2) setMaxResults(int i)
3) setFetchSize(int i)

i know what first two methods are doing but has doubt about the third. suppose my select query returns 50 records and i want to show only 10 records per page, can i use like following?


please give any other methods, if available in API.

Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setFirstResult - Set the first result to be retrieved.
setFetchSize - Set a fetch size for the underlying JDBC query.
setMaxResults - Set a limit upon the number of objects to be retrieved.

setFetchSize doesn't work and I think Hibernate guys are working on it.
setMaxResults first fetches the data from DB and then limits the objects.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!