org.midao.jdbc.core.handlers.output
Interface LazyOutputHandler<T,S>

All Superinterfaces:
OutputHandler<T>
All Known Implementing Classes:
BeanListLazyOutputHandler, MapListLazyOutputHandler

public interface LazyOutputHandler<T,S>
extends OutputHandler<T>

Lazy output handler handles output from LazyStatementHandler and allows lazy loading of data from it.

Useful in cases when you have to fetch a lot of data, but not all of it will be actually needed. For example if user searched for 100 pages but will be able to browse few pages only.

Please be informed that while using Lazy output handler you are responsible for manual resource handling. Please do not forget to use QueryRunnerService.commit() and close() after you finish with it's usage

Example usage: QueryRunnerService runner = MidaoFactory.getQueryRunner(ds, null, LazyStatementHandler.class); runner.setManualTransactionMode(true); ... LazyOutputHandler output = ... ... output.close(); runner.commit(); // use it even if you only executed query

Please be aware that functionality might be changed and most likely will be extended in future. Features which might be added in future: scrollability(not only forward) and updatability


Method Summary
 void close()
          Function closes all resources used by this Lazy output handler instance.
 S getNext()
          Returns next element from lazy list
 boolean hasNext()
          Checks if lazy list has next element
 
Methods inherited from interface org.midao.jdbc.core.handlers.output.OutputHandler
handle
 

Method Detail

hasNext

boolean hasNext()
Checks if lazy list has next element

Returns:
true if list has next element

getNext

S getNext()
Returns next element from lazy list

Returns:
next element from list. Null is returned in no value is present

close

void close()
Function closes all resources used by this Lazy output handler instance. Should be invoked every time you finished with reading data, otherwise resource leaks and/or errors might happen.



Copyright © 2013. All Rights Reserved.