|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.orbroker.BrokerConnection
net.sourceforge.orbroker.QueryableConnection
net.sourceforge.orbroker.Query
The query class. Read-only queries can use a Query object.
It wraps a Connection
object, and close()
should be called after use, to avoid
open connections, or connection pool leaks.
Broker.startQuery()
,
Broker.startQuery(int)
Method Summary | |
void |
addStatement(String id,
String sql)
Add temporary statement. |
void |
addStatement(String id,
String sql,
String resultObjectId)
Add temporary statement. |
void |
close()
Close query. |
void |
closeIterator(Iterator iterator)
Close iterator. |
Object |
getParameter(String name)
Get parameter. |
Iterator |
iterate(String statementID,
int fetchSize)
Return a live iterator. |
List |
selectMany(String statementID)
Return a list of 0..n objects. |
int |
selectMany(String statementID,
Collection resultCollection)
Fill Collection with 0..n objects. |
int |
selectMany(String statementID,
Collection resultCollection,
int startRow,
int rowCount)
Fill Collection with 0..n objects. |
List |
selectMany(String statementID,
int startRow,
int rowCount)
Return a list of 0..n objects. |
Object |
selectOne(String statementID)
Return a single result object. |
boolean |
selectOne(String statementID,
Object resultObject)
Use supplied result object to apply values to. |
Object |
selectOneFromMany(String statementID,
int fromRow)
Return one result object from a query containing many. |
void |
setParameter(String name,
Object value)
Set named parameter. |
void |
setTextReplacement(String key,
String value)
Set a text replacement value. |
void |
setTextReplacements(Properties textReplacements)
Set text replacement values. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public void close()
public final List selectMany(String statementID) throws BrokerException
List
will be returned if
result set is empty.
statementID
- Statement id
BrokerException
public final int selectMany(String statementID, Collection resultCollection) throws BrokerException
statementID
- Statement idresultCollection
- The collection where the result will be added.
BrokerException
public Iterator iterate(String statementID, int fetchSize)
Query
or Transaction
must be open.
statementID
- Statement idfetchSize
- Row buffer size
Iterator
of result objects.public final void closeIterator(Iterator iterator)
QueryableConnection.iterate(String, int)
. Only necessary if iterator has
not been exhausted by hasNext()
returning false
iterator
- The not fully iterated iterator.QueryableConnection.iterate(String, int)
public final int selectMany(String statementID, Collection resultCollection, int startRow, int rowCount) throws BrokerException
statementID
- Statement idresultCollection
- The collection where the result will be added.startRow
- The start row to return. First row is 1.rowCount
- The number of rows to return
BrokerException
public final List selectMany(String statementID, int startRow, int rowCount) throws BrokerException
List
will be returned if
result set is empty or if startRow
is greater than
the result set size.
statementID
- Statement idstartRow
- The start row to return. First row is 1.rowCount
- The number of rows to return
BrokerException
public final Object selectOne(String statementID) throws BrokerException, MoreThanOneRowException
statementID
- Statement id
null
if query returned 0
records.
BrokerException
MoreThanOneRowException
public final boolean selectOne(String statementID, Object resultObject) throws BrokerException, MoreThanOneRowException
statementID
- Statement idresultObject
- result object to map to
false
if query didn't return a record.
BrokerException
MoreThanOneRowException
public Object selectOneFromMany(String statementID, int fromRow) throws BrokerException
null
if query is empty or returnRow is out of range.
statementID
- Statement idfromRow
- Row to return. First row is 1.
BrokerException
public final void addStatement(String id, String sql) throws BrokerException, ConfigurationException
id
- The statement id.sql
- The SQL statement
BrokerException
ConfigurationException
public final void addStatement(String id, String sql, String resultObjectId) throws BrokerException, ConfigurationException
id
- The statement id.sql
- The SQL statementresultObjectId
- The result-object
id as
defined in the XML configuration file.
BrokerException
ConfigurationException
public final Object getParameter(String name)
BrokerConnection.setParameter(String, Object)
will be available with this method. Also if a stored procedure has
an output parameter that needs to be used as input in another
SQL statements, it's immediately available, i.e. there's no need
to code like this:
txn.setParameter("parm", txn.getParameter("parm"));
name
- parameter name
public final void setParameter(String name, Object value)
name
- parameter namevalue
- parameter valuepublic final void setTextReplacement(String key, String value)
{{key}}
string with the value.
This will override any value set on Broker.
key
- Text replacement keyvalue
- Text replacement valueBrokerConnection.setTextReplacements(Properties)
public final void setTextReplacements(Properties textReplacements)
{{key}}
type properties in an sql-statement with the values.
This will override any value set on Broker.
textReplacements
- The replacement values to set.BrokerConnection.setTextReplacement(String, String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |