JPAReaderPattern

JPAReaderPattern パターンは、OpenJPA を使用してデータベースからデータを検索するために使用されます。

サポートされるクラス

JPAReader クラスは、エンティティー・マネージャーの取得、ユーザー提供の照会の実行、および照会結果の繰り返しを行うタスクを実行します。 ユーザー・アプリケーションとともに persistence.xml ファイルをパッケージする必要があります。

必須プロパティー

以下は、このパターンの必須のプロパティーです。

表 1. 必須プロパティー. 次の表に、パターンの各必須プロパティーの名前と値を示します。
プロパティー名
PATTERN_IMPL_CLASS JPAReader パターン・インターフェースを実装するクラス
PERSISTENT_UNIT OpenJPA パーシスタント単位名。

オプション・プロパティー

以下は、このパターンのオプションのプロパティーです。

表 2. オプション・プロパティー. 次の表に、パターンの各オプション・プロパティーの名前、値、および説明を示します。
プロパティー名 説明
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>

トピックのタイプを示すアイコン 参照トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rgrid_btchpttrn9
ファイル名:rgrid_btchpttrn9.html