|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.database.DbRowProcessor
com.uwyn.rife.database.DbBeanFetcher<BeanType>
public class DbBeanFetcher<BeanType>
This class allows a ResultSet to be easily processed into bean
instance.
Multiple instances can be collected into a list when processing an
entire ResultSet, or as a single bean instance can be retrieved for
one row of a ResultSet. The default behavior is to not collect
instances.
| Constructor Summary | |
|---|---|
DbBeanFetcher(Datasource datasource,
Class<BeanType> beanClass)
Create a new DbBeanFetcher |
|
DbBeanFetcher(Datasource datasource,
Class<BeanType> beanClass,
boolean collectInstances)
Create a new DbBeanFetcher |
|
| Method Summary | |
|---|---|
BeanType |
getBeanInstance()
Get the last processed bean instance |
List<BeanType> |
getCollectedInstances()
Get the collected bean instances |
boolean |
gotBeanInstance(BeanType instance)
Hook method that can be overloaded to receive new bean instances as they are retrieved, without relying on the internal collection into a list. |
boolean |
processRow(ResultSet resultSet)
Process a ResultSet row into a bean. |
| Methods inherited from class com.uwyn.rife.database.DbRowProcessor |
|---|
clone, wasSuccessful |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DbBeanFetcher(Datasource datasource,
Class<BeanType> beanClass)
throws BeanException
datasource - the datasource to be usedbeanClass - the type of bean that will be handled
BeanException - thrown if there is an error getting
information about the bean via the beanClass
public DbBeanFetcher(Datasource datasource,
Class<BeanType> beanClass,
boolean collectInstances)
throws BeanException
datasource - the datasource to be usedbeanClass - the type of bean that will be handledcollectInstances - true if the fetcher should
collected the bean instances; false if otherwise
BeanException - thrown if there is an error getting
information about the bean via the beanClass| Method Detail |
|---|
public boolean processRow(ResultSet resultSet)
throws SQLException
ResultSet and the resulting bean will be stored and be accessible
via getBeanInstance()
processRow in class DbRowProcessorresultSet - the ResultSet from which to process the
row
true if a bean instance was retrieved; or
false if otherwise
SQLException - thrown when there is a problem processing
the rowDbQueryManager.fetch(ResultSet, DbRowProcessor),
DbRowProcessor.wasSuccessful()public boolean gotBeanInstance(BeanType instance)
instance - the received bean instance
true if the bean fetcher should continue to
retrieve the next bean; or
false if the retrieval should stop after this bean
public BeanType getBeanInstance()
public List<BeanType> getCollectedInstances()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||