The pureQuery Generator utility generates classes that implement both an interface that declares annotated methods and extend an implementation of the Data interface. Because applications generally do not need access to the many methods of the Data interface, at run time the methods in DataFactory that instantiate implementation classes for particular annotated-method interfaces return instances of those interfaces.
For example, if one of these DataFactory methods instantiates an implementation of the interface MyInterface, and myObject is set to the return value of the method, then myObject is of type MyInterface. For your application to access the Data methods in myObject, the application must cast myObject to a Data object.
When the pureQuery Generator utility generates an implementation class, by default that class extends an implementation of the Data interface that is named BaseData. The implementation class can, however, extend a different class that itself extends BaseData.
Data objects are not thread safe. Do not share them between multiple threads. Use a Data object only in the same thread that it was created in.
To extend your class from an implementation class that the Generator utility generates:
package customer; public interface CommonInterface { public void startHeterogeneousBatch (); // this method "renames" the Data Interface method public int[][] endHeterogeneousBatch (); // this method "renames" the Data Interface method public int dynamicSQLUpdate (String updateSQL, Object... parameters); // this method "renames" the Data Interface method public <T> T[] dynamicQueryArray (String sql, Class<T> returnClass, Object... parameters); // this method "renames" the Data Interface method public void commit (); public void rollback (); // any other Data Interface method can be coded here also }
package customer; public class BaseData extends com.ibm.pdq.runtime.generator.BaseData implements CommonInterface { public <T> T[] dynamicQueryArray (String sql, Class<T> returnClass, Object... parameters) { return queryArray (sql, returnClass, parameters); } public int dynamicSQLUpdate (String updateSQL, Object... parameters) { return update (updateSQL, parameters); } public void startHeterogeneousBatch () { startBatch (heterogeneousModify__); return; } public int[][] endHeterogeneousBatch () { return endBatch (); } }
Notice that this class extends com.ibm.pdq.runtime.generator.BaseData.
import com.ibm.pdq.annotation.Update; public interface AutoGeneratedKeysInterface { @Update(sql = "insert into MYEMPLOYEE (name, salary, deptno) values(:name, :salary, :deptno)") int createEmployee (MyEmployeeBean bean); }
import com.ibm.pdq.annotation.Update; public interface AutoGeneratedKeysInterface extends customer.CommonInterface { @Update(sql = "insert into MYEMPLOYEE (name, salary, deptno) values(:name, :salary, :deptno)") int createEmployee (MyEmployeeBean bean); }
When you use the pureQuery Generator to generate the implementation class for this interface, for the option baseDataOverride you specify customer.BaseData.