JPAReaderPattern
JPAReaderPattern 패턴은 OpenJPA를 사용하여 데이터베이스에서 데이터를 검색하는 데 사용됩니다.
클래스 지원
JPAReader 클래스는 엔티티 관리자 얻기, 사용자가 제공한 조회 실행 및 조회 결과 반복의 태스크를 수행합니다. persistence.xml 파일은 사용자 애플리케이션과 패키지해야 합니다.
필수 특성
패턴에 다음 특성이 필요합니다.
특성 이름 | 값 |
---|---|
PATTERN_IMPL_CLASS | JPAReader Pattern 인터페이스를 구현하는 클래스 |
PERSISTENT_UNIT | OpenJPA 지속적 단위 이름. |
선택적 특성
다음 특성은 패턴에 대해 선택사항입니다.
특성 이름 | 값 | 설명 |
---|---|---|
디버그 | true 또는 false(기본값은 false) | 이 일괄처리 데이터 스트림에 대한 자세한 추적을 사용으로 설정합니다. |
openjpa.Log | DefaultLevel=WARN,SQL=TRACE | JPA 로그 설정 |
EnablePerformanceMeasurement | true 또는 false(기본값은 false) | GenericXDBatchStep을 사용 중인 경우, 일괄처리 데이터 스트림과 processRecord 메소드에서 소요된 전체 시간을 계산합니다. |
EnableDetailedPerformanceMeasurement | true 또는 false(기본값은 false) | 일괄처리 데이터 스트림의 각 메소드에서 소요된 시간의 자세한 추가 분석을 제공합니다. |
인터페이스 정의
public interface JPAReaderPattern {
/**
* This method is invoked during the job setup phase.
*
* @param props properties provided in the xJCL
*/
public void initialize(Properties props);
/**
* This method should retrieve values for the various columns for the current row from
* the given Iterator object. Typically this data would be used to populate an intermediate
* object which would be returned.
* @param listIt
* @return
*/
public Object fetchRecord(Iterator listIt);
/**
* This method should return a JPQL query that will be used during setup of the stream to
* retrieve all relevant data that would be processed part of the job steps.
* @return object to be used during process step.
*/
public String getInitialLookupQuery();
/**
* This method gets called during Job Restart. The restart token should be used to create
* a JPQL query that retrieves previously unprocessed records. Typically the restart token
* is the primary key in the table and the query would get all rows with
* primary key value > restarttoken
* @param restartToken
* @return The restart query
*/
public String getRestartQuery(String restartToken);
/**
* This method gets called just before a checkpoint is taken.
* @return The method should return a string value identifying the last record read by the stream.
*/
public String getRestartTokens();
}
xJCL 예
<batch-data-streams>
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="PERSISTENT_UNIT" value="hellojpa"/>
<prop name="debug" value="true"/>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.samples.JPAInputStream"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.JPAReader</impl-class>
</bds>
</batch-data-streams>