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.

Chapter 11 – Annotated-Method Programming Style 231<br />

Listing 11.29- Changes to the displayEmployeeInformation method to update a<br />

last name<br />

// Update the first name in the database<br />

updateCount = data.updateEmployeeFirstName (employee);<br />

Listing 11.30 -Changes to the displayEmployeeInformation method to update a<br />

first name<br />

11.6.2.3 Test the "Change Employee Information" screen<br />

Save and test your application. Supply 000030 to login as Sally Kwan. On the main<br />

menu, select option 2 to change information about Sally. Then, return to the main menu<br />

and select option 4 to go to the “Company Employees” screen and find Heather A.<br />

Nicholls, one of the employees that Sally manages. View information about Heather, and<br />

then change information for her.<br />

11.7 Tooling Support for Annotated Methods and Generated Code<br />

General <strong>pureQuery</strong> tooling support was introduced starting in Chapter 3. The following<br />

features provide support that is specifically tailored to code generated using the <strong>pureQuery</strong><br />

annotated method API.<br />

11.7.1 Generating XML file to override the SQL statements in interfaces<br />

When the implementation class is generated by the <strong>pureQuery</strong> Generator for an interface<br />

that defines annotated methods, you can use an XML file to specify or override the SQL<br />

statements that those methods use. You can also use the same XML file to override how<br />

the columns in a database object, such as a table or view, map to the properties of a bean.<br />

To specify an XML configuration file, use the xmlFile option when you invoke the<br />

<strong>pureQuery</strong> Generator.<br />

You might want to override SQL statements in an XML file when you want to use the same<br />

interface in another application that runs against a different database. For example,<br />

assume that your interface contains the following method:<br />

@Select(sql=”SELECT CUSTID, NAME FROM Customer WHERE STOREREGION=?1”)<br />

Iterator getCustomersInRegion(int r)<br />

In the XML configuration file for the other application, you can override the SQL like this:<br />

<br />

<br />

<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!