As the pureQuery Generator creates an implementation for an annotated method in the interface, it checks the XML configuration file for an SQL statement to use if the method is defined with an empty annotation, or for an override of the SQL statement that is used in the annotation of the method. The pureQuery Generator also checks the XML configuration file for any beans that the file might refer to.
To specify an XML configuration file, use the xmlFile option when you invoke the pureQuery Generator.
The following examples demonstrate situations in which you might want to use XML configuration files.
For example, you can define an annotated method in the interface like this:
@Select
Iterator<Customer> getCustomersInRegion(int r);
In the XML configuration file for one application, you define the SQL statement that you want to use for this method:
<named-native-query name="myPackage.CustomerInterface#getCustomersInRegion(int)">
<query>
<![CDATA[SELECT CUSTID, NAME FROM Customer WHERE STOREREGION=?1]]>
</query>
</named-native-query>
In the XML configuration file for the other application, you do the same thing:
<named-native-query name="myPackage.CustomerInterface#getCustomersInRegion(int)">
<query>
<![CDATA[SELECT ID, NAME FROM CUST WHERE REGION=?1]]>
</query>
</named-native-query>
For example, the interface might contain this definition for an annotated method that the first application uses:
@Select(sql="SELECT CUSTID, NAME FROM Customer WHERE STOREREGION=?1")
Iterator<Customer> getCustomersInRegion(int r);
In the XML configuration file for the other application, you can override the SQL like this:
<named-native-query name="myPackage.CustomerInterface#getCustomersInRegion(int)">
<query>
<![CDATA[SELECT ID, NAME FROM CUST WHERE REGION=?1]]>
</query>
</named-native-query>