|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.boylesoftware.cb2.GenericFetchExecutor
Generic FetchExecutor
implementation used by the DAO by default
when no other DAO plugin implementing FetchExecutor
interface
is installed. This implementation uses JDBC scrollable result sets for
paginated results. In general, it tries to use the most standard JDBC
features to implement functionality.
Field Summary | |
protected ApplicationContext |
appCtx
The application context. |
protected java.sql.Connection |
con
The database connection. |
protected DAOConfig |
daoConfig
The DAO configuration. |
protected FetchResultDescriptor |
fetchResultDescriptor
Reference to the fetch result descriptor instance passed to the DAO for the call. |
protected int |
page
Requested page starting from zero. |
protected int |
pageSize
Requested page size. |
protected java.lang.String |
query
Text of the SQL query to be executed. |
protected java.lang.Object[] |
queryParams
The query parameters as passed to the DAO. |
protected java.sql.ResultSet |
rs
The result set object. |
protected java.sql.Statement |
stmt
The statement object. |
protected boolean |
usePreparedStatement
Set to true if the stmt is an instance of
java.sql.PreparedStatement . |
Constructor Summary | |
GenericFetchExecutor()
|
Method Summary | |
void |
destroy()
Sets null to all internal member variables. |
java.sql.Statement |
execute()
Executes the stmt statement and sets the rs
member variable. |
void |
finish(int nRowsProcessed,
java.util.List result)
Finishes query execution and result set processing and sets up fetch result descriptor in fetchResultDescriptor member
variable if it is not null . |
java.sql.ResultSet |
getResultSet()
Gets the result set. |
void |
init(DAOConfig daoConfig,
java.sql.Connection con,
java.lang.Class dmClass,
java.lang.String query,
java.lang.Object[] queryParams,
int page,
int pageSize,
FetchResultDescriptor fetchResultDescriptor)
Initializes the executor setting up internal member variables. |
java.sql.Statement |
prepareStatement()
Creates a statement object. |
void |
setApplicationContext(ApplicationContext appCtx)
Sets the application context. |
boolean |
setToTheFirstRow()
Positions the result set cursor to the first row of the requested data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ApplicationContext appCtx
protected DAOConfig daoConfig
init
method.
protected java.sql.Connection con
init
method.
protected java.lang.String query
init
method.
protected java.lang.Object[] queryParams
init
method.
protected int page
init
method.
protected int pageSize
init
method.
protected FetchResultDescriptor fetchResultDescriptor
null
. Set by the init
method.
protected java.sql.Statement stmt
protected boolean usePreparedStatement
true
if the stmt
is an instance of
java.sql.PreparedStatement
.
protected java.sql.ResultSet rs
Constructor Detail |
public GenericFetchExecutor()
Method Detail |
public void setApplicationContext(ApplicationContext appCtx)
setApplicationContext
in interface DAOPlugin
appCtx
- the application context.public void init(DAOConfig daoConfig, java.sql.Connection con, java.lang.Class dmClass, java.lang.String query, java.lang.Object[] queryParams, int page, int pageSize, FetchResultDescriptor fetchResultDescriptor)
init
in interface FetchExecutor
daoConfig
- the DAO configuration.con
- the database connection to be used.dmClass
- class of the top-level DMs to be returned by the call.query
- the SQL query text.queryParams
- values for the query parameters, null
or
empty array if the query needs no parameters.page
- number of the result set page requested, starting from zero.pageSize
- number of records in one result set page, equal or less
than zero if result set pagination is not requested.fetchResultDescriptor
- the FetchResultDescriptor
instance or null
if no result info requested.public java.sql.Statement prepareStatement() throws java.sql.SQLException
stmt
member variable.
prepareStatement
in interface FetchExecutor
java.sql.PreparedStatement
.
java.sql.SQLException
- if a JDBC error happens.public java.sql.Statement execute() throws java.sql.SQLException
stmt
statement and sets the rs
member variable.
execute
in interface FetchExecutor
java.sql.SQLException
- if a JDBC error happens.public java.sql.ResultSet getResultSet()
getResultSet
in interface FetchExecutor
public boolean setToTheFirstRow() throws java.sql.SQLException
setToTheFirstRow
in interface FetchExecutor
true
if the cursor has been set or
false
if there is not data (for example the result set is
empty or the requested page does not exist).
java.sql.SQLException
- if a JDBC error happens.public void finish(int nRowsProcessed, java.util.List result)
fetchResultDescriptor
member
variable if it is not null
.
finish
in interface FetchExecutor
nRowsProcessed
- number of result set rows processed by the DAO.result
- the result, which will be returned by the DAO to the
caller as a java.util.List
of DMs.public void destroy()
null
to all internal member variables.
destroy
in interface FetchExecutor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |