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.

238<br />

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

11.9 Advanced features<br />

The annotated-method style provides many advanced features that are outside of the<br />

scope of this book. This list describes some of them. For details about using these<br />

features, refer to the IBM Optim <strong>pureQuery</strong> Runtime documentation.<br />

• Positioned updates and deletes: You can associate @Select<br />

annotated methods with @Update methods to allow you to perform<br />

positioned updates and deletes on the query result created by an SQL<br />

SELECT statement.<br />

• Exception handling: The annotated-method style and inline style APIs<br />

throw exceptions of the type<br />

com.ibm.pdq.runtime.exception.DataRuntimeException.<br />

Utility methods on these exceptions provide helpful information about the<br />

causing exception.<br />

• Hooks: You can use implementations of the interface<br />

com.ibm.pdq.runtime.statement.Hook to provide methods that<br />

bracket the execution of the annotated and inline methods.<br />

• Batching SQL statements: If you are using the IBM Data Server Driver<br />

for JDBC and SQLJ, you can use heterogeneous batching to execute<br />

multiple different SQL statements that do not return query results in a<br />

single trip to the database.<br />

• Queries over collections: You can use the SQL syntax to perform<br />

queries over in-memory collections of data.<br />

• Combining the contents of two interfaces into a single package in<br />

the database: You can create interfaces that extend multiple interfaces of<br />

annotated methods. When you bind the extending interfaces in the<br />

database, the StaticBinder utility puts the SQL statements from the<br />

different interfaces into the same package.<br />

• Specifying SQL statements in XML files: You can specify an XML file<br />

to the Generator utility to provide the SQL statements for the annotated<br />

methods. This allows you to use a single interface for SQL statements<br />

that you need to execute against multiple databases, even if the SQL<br />

syntax varies between the databases. Use the option -xmlFile to<br />

specify this XML file.<br />

11.10 Summary<br />

The annotated-method style is an easy-to-use API for accessing databases. Under the<br />

annotated-method style, you define annotated methods in an interface that specify the SQL<br />

statements that you want processed, the input parameters that you will use to specify the

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

Saved successfully!

Ooh no, something went wrong!