JPAReaderPattern
JPAReaderPattern パターンは、OpenJPA を使用してデータベースからデータを検索するために使用されます。
サポートされるクラス
JPAReader クラスは、エンティティー・マネージャーの取得、ユーザー提供の照会の実行、および照会結果の繰り返しを行うタスクを実行します。 ユーザー・アプリケーションとともに persistence.xml ファイルをパッケージする必要があります。
必須プロパティー
以下は、このパターンの必須のプロパティーです。
プロパティー名 | 値 |
---|---|
PATTERN_IMPL_CLASS | JPAReader パターン・インターフェースを実装するクラス |
PERSISTENT_UNIT | OpenJPA パーシスタント単位名。 |
オプション・プロパティー
以下は、このパターンのオプションのプロパティーです。
プロパティー名 | 値 | 説明 |
---|---|---|
debug | 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>