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.

68<br />

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

Figure 3.3 - Generating a <strong>pureQuery</strong> bean and interface from a database table<br />

Click Next, and on the second page of the wizard you can select to generate a test<br />

program to execute some of the generated CRUD (create, retrieve, update and delete)<br />

methods of the annotated-method style interface you selected in the previous page. You<br />

can also select the option to generate an inline-style class. These test programs can be<br />

generated either as a class with a main method or as JUnits. For the test classes, you can<br />

either select to include the connection information such as the database connection string<br />

(url) and user ID or pass these two values as arguments. The password has to be passed<br />

as an argument when executing your test class. For generating the bean, you can choose<br />

to change the field names as required and get the mapping to the database automatically<br />

generated for you. The <strong>pureQuery</strong> APIs, for example, use beans to hold the result of a<br />

select statement—a bean represents a row/record in a database. You can also choose to<br />

generate public fields or protected fields with public getters and setters. If you need custom<br />

Java type mappings, you can simply change the default ones in the Bean Fields part of the<br />

code generation wizard as shown in Figure 3.4, or use the @Handler annotation.

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

Saved successfully!

Ooh no, something went wrong!