>> I often need to iterate through a Collection and was wondering if its
better
>> to return the collection the client, which is by default serializable or
>> would it make more sense to wrap the collection such that you can iterate
>> through it remotely?  I would like to know what experiences people have
had
>> with either or another approach that might be preferable.  Any pros or
cons
>> to either approach?


1. Use a session bean to get a "page" of data, a Vector or array of simple
Java types
with a fixed amount of rows, e.g.
int PAGE_SIZE = 20;

2. When the client wants data it asks the session bean for a page of data.
The client says how many rows and where to begin, e.g. "get 20 rows starting
at 40"

3. The UI allows the user to navigate visualizing cached data or asking the
server
for additional pages, in a way that is transparent to the user,
e.g. using Swing and a ListModel you should put the paging logic in method
getElementAt(int)

The idea is to keep memory requirements in the client low, network use
moderate.
This scheme allows the client to ask for all elements in a million-rows
table and get only
the rows she will actually see with a couple of network round trips.

The main problem is that pages way up the list will take a lot more time
than pages at the
beguinning of the list. Performance can be a lot better putting the session
beans inside
the database, if you are using Oracle 8i. Note Oracle 8i at present (8.1.5)
only support session beans.

Hope that helps

    Javier Borrajo
    www.tid.es

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to