To execute pureQuery code with static SQL, you must set
the executionMode property to "STATIC".
Before you begin
The package that contains the static SQL must be bound
to the database that the application uses. If you set the executionMode
property to "STATIC", but the package is not bound,
pureQuery throws an exception. pureQuery does not revert to dynamic
SQL.
Procedure
To set the execution mode to STATIC,
use one of the following methods:
- Pass a properties object to the DataFactory when
creating an implementation of an interface, specifying executionMode="STATIC"
as one of the properties, as in the following example.
con = DriverManager.getConnection...;
java.util.Properties myPdqProperties = new java.util.Properties();
myPdqProperties.put("pdq.executionMode", "STATIC");
BasicAnnotatedMethodInterface bami =
DataFactory.getData(BasicAnnotatedMethodInterface.class, con,
myPdqProperties);
- Set a JVM system property when invoking the JRE, as in
the following example.
java -Dpdq.executionMode="STATIC" myjavapkg.myPDQapp
- Set the execution mode of the application to STATIC by
using a file named pdq.properties. You can place this file
on the file system or in your application's classpath.
Here is
an example of a properties file. The properties are specified in pairs
of keys and values. The # symbol at the beginning of a line indicates
that the line contains a comment.
# Set the execution mode.
pdq.executionMode="STATIC"
By default, pureQuery expects the name of the file
to be pdq.properties and the location of the file to be in your application's
classpath.
If you use a different file name, place the file
in a different location, or both, use the configFile JVM system property
to point to the file when you run your application, as follows:
-Dpdq.configFile=path-and-file-name or resource-name Java-package.application
If
you are developing a Web application, place the pdq.properties file
in your application's WEB-INF/classes folder
or in a JAR file in the WEB-INF/lib folder.
If you are developing a stand-alone application,
place the pdq.properties file in any folder or JAR file that is in
the classpath for the application.