This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes To Retrieve multiple rows separately Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "To Retrieve multiple rows separately" Watch "To Retrieve multiple rows separately" New topic

To Retrieve multiple rows separately

nami shekar

Joined: Sep 14, 2011
Posts: 17
How can I retrieve only the first n rows, second n rows of a database (using a particular WHERE clause ? )
For example, if a SELECT typically returns a 1000 rows,
how do first retrieve the 100 rows, then go back and retrieve the next 100 rows and so on ?

Suggestions or comments are welcome
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
If you are using JPA, you can use the firstResult and maxResults properties on the Query.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
nami shekar

Joined: Sep 14, 2011
Posts: 17
Thanks James,
You are right. I could use firstResult and maxResults to get it done.
I agree. Here's the link:
subject: To Retrieve multiple rows separately
jQuery in Action, 3rd edition