pureQuery Generator 유틸리티는 어노테이션이 있는 메소드를 선언하는 인터페이스를 구현하고 Data 인터페이스의 구현을 확장하는 클래스를 생성합니다. 애플리케이션은 일반적으로 Data 인터페이스의 여러 메소드에 액세스할 필요가 없으므로 런타임 시 특정 어노테이션이 있는 메소드 인터페이스에 대한 구현 클래스를 인스턴스화하는 DataFactory의 메소드는 해당 인터페이스의 인스턴스를 리턴합니다.
예를 들어, 이러한 DataFactory 메소드 중 하나가 인터페이스 MyInterface의 구현을 인스턴스화하고 myObject가 메소드의 리턴 값으로 설정되는 경우, myObject의 유형은 MyInterface입니다. 애플리케이션이 myObject의 Data 메소드에 액세스하려면 애플리케이션이 myObject를 Data 오브젝트에 캐스트해야 합니다.
pureQuery Generator 유틸리티가 구현 클래스를 생성하는 경우, 기본으로 해당 클래스는 BaseData로 이름 지정된 Data 인터페이스의 구현을 확장합니다. 그러나 구현 클래스는 자체적으로 BaseData를 확장하는 다른 클래스를 확장할 수 있습니다.
데이터 오브젝트는 스레드 안전하지 않습니다. 여러 스레드에서 공유하지 마십시오. Data 오브젝트가 작성된 동일한 스레드에서만 사용하십시오.
Generator 유틸리티가 생성한 구현 클래스에서 클래스를 확장하려면 다음을 수행하십시오.
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 (); } }
이 클래스가 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); }
pureQuery Generator를 사용하여 이 인터페이스에 대한 구현 클래스를 생성하는 경우, baseDataOverride 옵션에 customer.BaseData를 지정합니다.