In my data layer, I will be querying my data store to fetch a single column. But the rows will be large enough containing thousands of records.
My JDBC block of code will be something along these lines:
I have been bitten many times before by memory exhaustion errors. I want to avoid that and be in the know of the convention to take care of transfer of humongous list. How would you go about if this was your problem.
One more question that strikes me to be an issue is - Does it justify creating a Java bean when I have only one field?
Mods, don't know if this is more suited to the Java in general forum.
Send it to the client which is not necessarily a web presentation layer but a normal main method of a class. And when that is done read it one by one.
Joined: Mar 17, 2012
The nature of the client is important because that determines if it makes sense to retrieve those thousands at all or not. Clients intended to be read by humans should not return more than 100 records at a time because humans won't be able to analyse that volume anyway. Typically one uses the ValueListHandler pattern to implement server side pagination and return the data in smaller chunks. That way you can control scalability by adjusting the page size. Of course this only works if the data can be processed/viewed in chunks.
It appears to me that I am out of options here as the client should not be able to read records just that it should be transferred to it. I think I might have been kind of vague with the word read. Nonetheless I learned how the pagination is handled in the presentation layer by making use of Value List Handler and for that I am quite grateful.