org.oddjob.sql
Class SQLResultsBean

java.lang.Object
  extended by org.oddjob.beanbus.AbstractDestination<F>
      extended by org.oddjob.beanbus.AbstractFilter<Object,Object>
          extended by org.oddjob.sql.SQLResultsBean
All Implemented Interfaces:
Iterable<Object>, Collection<Object>, BusFilter<Object,Object>, Outbound<Object>

public class SQLResultsBean
extends AbstractFilter<Object,Object>

Description

Captures SQL results in a bean that has properties to provide those results to other jobs.

The properties row, rows, rowSets properties in turn expose the results as beans so the colums can be accessed as properties.

If a single query result set consisted of a single row:

 NAME        AGE
 John        47
 
then:
 row.NAME == rows[0].NAME == rowSets[0][0].NAME == 'John'
 row.AGE == rows[0].AGE == rowSets[0][0].AGE == 47
 
If a single query result set consisted of more than a single row:
 NAME        AGE
 John        47
 Jane        72
 
then the row property is unavailable and any attempt to access it would result in an exception, and:
 rows[1].NAME == rowSets[0][1].NAME == 'Jane'
 rows[1].AGE == rowSets[0][1].AGE == '72'
 
If the query results in a multiple query result set:
 NAME        AGE
 John        47
 Jane        72
 
 FRUIT       COLOUR
 Apple       Green
 
then the row property and the rows properties are unavailable and any attempt to access either would result in an exception. The rowSets property can be used as follows:
 rowSets[0][1].NAME == 'Jane'
 rowSets[0][1].AGE == '72'
 rowSets[1][0].FRUIT == 'Apple'
 rowSets[1][0].COLOUR == 'Green'
 
The case of the properties depends on the database used.

Any attempt to access a row or row set that doesn't exist will result in an exception.

Example

See SQLJob for an example.
Author:
rob

Constructor Summary
SQLResultsBean()
           
 
Method Summary
 void addBeans(List<?> beans)
           
protected  Object filter(Object bean)
           
 Object getRow()
           
 int getRowCount()
           
 Object[] getRows()
           
 int getRowSetCount()
           
 Object[][] getRowSets()
           
 int getUpdateCount()
           
 Integer[] getUpdateCounts()
           
 void setBusConductor(BusConductor busConductor)
           
 
Methods inherited from class org.oddjob.beanbus.AbstractFilter
add, getName, getTo, setName, setTo, toString
 
Methods inherited from class org.oddjob.beanbus.AbstractDestination
addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

SQLResultsBean

public SQLResultsBean()
Method Detail

setBusConductor

@Inject
public void setBusConductor(BusConductor busConductor)

filter

protected Object filter(Object bean)
Specified by:
filter in class AbstractFilter<Object,Object>

addBeans

public void addBeans(List<?> beans)

getRowCount

public int getRowCount()

Property: rowCount

Description: The total number of rows returned by all the queries.

Required: Read only.


getRowSetCount

public int getRowSetCount()

Property: rowSetCount

Description: The number of rows sets, which will be the same as the number of queries that returned results.

Required: Read only.


getRowSets

public Object[][] getRowSets()

Property: rowSets

Description: A two dimensional array of all of the rows that each individual query returned.

Required: Read only.


getRows

public Object[] getRows()

Property: rows

Description: An array of the rows when the query set contains only one result returning query. If no results were returned by the queries this property is null. If there are more than one result sets an exception will occur.

Required: Read only.


getRow

public Object getRow()

Property: row

Description: The result of a query when only one result is expected. If no results were returned by the queries this property is null. If there are more than one row an exception will occur.

Required: Read only.


getUpdateCounts

public Integer[] getUpdateCounts()

Property: updateCounts

Description: An Array of the update counts, one element per data modification statement.

Required: Read only.


getUpdateCount

public int getUpdateCount()

Property: updateCount

Description: The total update count for all queries.

Required: Read only.