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 Loading 1000 records from database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Loading 1000 records from database." Watch "Loading 1000 records from database." New topic
Author

Loading 1000 records from database.

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
loads record with primary key value as 1. Suppose i want to load 1000 records, what i will have to do?


kunal
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

When you say "load 1000" records do you mean you want to load all the records (and there happens to be 1000 of them) or do you mean to load the first 1000?

Sean


I love this place!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You need to run a query.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
I have to load 1000's of records in jsp. (u may consider 1st 1000records)
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

...and what defines the "first" 1000 in your application?
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Paul, Sean please elaborate
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What defines "the first 1000" records? You will need some way of specifying this in your data model, i.e. an auto incrementing surrogate key, or a "creation date" field of some kind. Otherwise there is no way to know what "first 1000" actually means. The query you would write to get these depends on that bit of info.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
i want records of students from roll no 1 to roll no 1000.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

If "roll no" a field in your table?
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Yes, it is.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

So in HQL your query could perhaps use a between operator - something like:

or if you prefer using Criteria queries you would use a between Restriction, e.g. :


One thing to consider is 1000 records on one web page is probably quite a lot. Unless you know for certain your users want to look at 1000 results at once I'd maybe consider reducing the size of result set you show. For example Google only show about 10 - 20 results on one page.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks Paul
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You are welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading 1000 records from database.