16.10.2015 Views

Getting Startedwith pureQuery

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

188<br />

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

10.2.2.3 Test the application<br />

Now, run hrm.inProgress.pdqInlineStyle.HumanResourcesManager. When the<br />

application prompts you for an employee number, use 000030. When the main menu<br />

displays, immediately select the menu option 0 to exit the application. We have not<br />

finished implementing the other screens yet, so they will not work.<br />

10.3 Executing SQL SELECT statements<br />

The Data interface provides many queryXXX methods for executing SQL SELECT<br />

statements. Choose the one you want to use based on the format in which you want to<br />

retrieve your data and on any other parameters that you want to be able to specify.<br />

10.3.1 Choosing the return type<br />

Use the following questions as a guide to help you select the right return type.<br />

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

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

Class returnClass store the contents of each row in an instance of<br />

returnClass.<br />

o If returnClass is a <strong>pureQuery</strong> bean, <strong>pureQuery</strong> creates an instance of<br />

returnClass and sets the values of its properties according to the values<br />

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

set of mapping rules to determine the bean property that represents each<br />

column that is selected from the database. When <strong>pureQuery</strong> cannot find a<br />

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

not store the value of that column in the bean.<br />

o If returnClass is not a <strong>pureQuery</strong> bean, <strong>pureQuery</strong> constructs an object of<br />

type returnClass and attempts to store the contents of the first column<br />

of the query result in that object.<br />

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

com.ibm.pdq.runtime.handlers.RowHandler object: queryXXX<br />

methods that have a parameter RowHandler rowHandler use<br />

rowHandler to create the object that contains each row. Chapter 13 discusses<br />

handlers.<br />

• A java.util.Map object: queryXXX methods that do not<br />

have a parameter Class returnClass or a parameter<br />

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

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

values are the contents of the columns.

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

Saved successfully!

Ooh no, something went wrong!