ScArcher2
ScArcher2

Reputation: 87257

What is the best way to present data from a very large resultset?

I'm writing a report view of an audit trail, and I need to display this in a .jsp. What's the "best" way to get the data from the database to the screen?

We're using Spring for dependency injection, Data Access Objects, and Hibernate. I can use hibernate or straight jdbc for this report.

If I load all the records into memory I run out of memory.

Any ideas that don't involve running the query in the jsp?

Upvotes: 2

Views: 1894

Answers (4)

John Nilsson
John Nilsson

Reputation: 17307

Another way to do it is to use scroll() to stream one row at the time.

Upvotes: 1

Brian Matthews
Brian Matthews

Reputation: 8596

The Display Tag Library is very good at presenting paginated result sets in servlets or portlets. But it normally works with the whole list loaded into memory. So you will have to do a little work to get it to work with paginated result sets by implementing the org.displaytag.pagination.PaginatedList interface. There is a tutorial on the Display Tag web site. There isn't very much to the tutorial but then again implementing the interface is pretty easy.

Upvotes: 2

delfuego
delfuego

Reputation: 14265

It seems like this is a natural place to use pagination of your Hibernate results -- run the query at the Servlet level, and paginate results in a way similar to how this person describes:

http://blog.hibernate.org/Bloggers/Everyone/Year/2004/Month/08/Day/14#pagination

This is the easiest method of implementing Hibernate pagination I've seen...

Upvotes: 6

EvilEddie
EvilEddie

Reputation: 1035

Just use paging and only load a certain number of rows on the page at a time.

Upvotes: 1

Related Questions