16.10.2015 Views

Getting Startedwith pureQuery

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

246<br />

<strong>Getting</strong> Started with <strong>pureQuery</strong><br />

format specified by the name and parameters of the method. When you call a getXXX<br />

method and there is no next (or first) query result, the method closes the<br />

StoredProcedureResult object and returns null.<br />

The query result formats that the getXXX methods in the StoredProcedureResult<br />

interface provide are very similar to the query result formats that the queryXXX methods of<br />

the com.ibm.pdq.runtime.Data interface provide. Use the following questions as a<br />

guide to help you select the right return type:<br />

• What format do you want to use for each row?<br />

o<br />

o<br />

o<br />

A <strong>pureQuery</strong> bean or a scalar object: getXXX methods that have<br />

a parameter Class returnClass store the contents of<br />

each row in an instance of returnClass.<br />

• If returnClass is a <strong>pureQuery</strong> bean, <strong>pureQuery</strong><br />

creates an instance of returnClass and sets the<br />

values of its properties according to the values of the<br />

columns returned from the database. <strong>pureQuery</strong> uses<br />

the rules defined in Section 3.3.1 to determine the bean<br />

property that represents each column that is selected<br />

from the database. When <strong>pureQuery</strong> cannot find a<br />

property that represents a column in the SQL statement,<br />

<strong>pureQuery</strong> does not store the value of that column in the<br />

bean.<br />

• If returnClass is not a <strong>pureQuery</strong> bean, <strong>pureQuery</strong><br />

constructs an object of type returnClass and attempts<br />

to store the contents of the first column of the query<br />

result in that object.<br />

An object of a specific type, constructed by a<br />

RowHandler object: getXXX methods that have a<br />

parameter RowHandler rowHandler use rowHandler<br />

to create the object that contains each row.<br />

A java.util.Map object: queryXXX<br />

methods that do not have a parameter Class<br />

returnClass or a parameter RowHandler<br />

rowHandler return the contents of each row in a<br />

Map object, in which the keys are the column<br />

labels, and the values are the contents of the columns.<br />

• What object do you want to use to contain all of the rows?<br />

o<br />

An array: getArray methods return an array in which each entry<br />

represents a row.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!