Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get the records by portion from a database

 
Mohamed Amri
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I don't want to load all the database table records in the memory while visulizing it on the screen. On the creen the user can scroll over the records, and only 10 records are displayed at a time. Currently, When the user requires the Next 10 records to be displayed, I have to iterate through the whole list (The whole list is always in memory). I dont'want to load the whole list in memory (Very big list); I want to keep only a part of it (1000 records), when the user requires the Next 10 records to be displayed, If this Next 10 records are not available in the list in memory, that time I will have to refresh my List in memory by the Next 1000 records from the database.

This is my question, Does Hibernate allow to load a part of the records of a database table. How can I do that ?

Thanks !
 
Madan Prabhu Durai
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya using setFirstResult and setMaxResults methods..
like this
Query q = session.createQuery("...");
q.setFirstResult(start);
q.setMaxResults(length);

For detail info, check this link
http://www.javalobby.org/java/forums/t63849.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic