WebSphere Extended Deployment Compute Grid, Version 6.1.1
             オペレーティング・システム: AIX , HP-UX, Linux, Solaris, Windows,


JPAReaderPattern

このパターンは、OpenJPA を使用してデータベースからデータを取得する場合に使用されます。

サポート・クラス

JPAREADER
  1. JPAReader: 現在、JPAReader は、グローバル・トランザクションには参加しません。これは、JDBC 接続 URL とドライバー名を使用してデータベースと通信します。今後のバージョンでは、 EJB 3.0 フィーチャー・パックがあれば、管理トランザクションをサポートするようになります。

必須プロパティー

表 1. 必須プロパティー
プロパティー
PATTERN_IMPL_CLASS JPAReaderPattern インターフェースを実装するクラス
openjpa.ConnectionDriverName JDBC ドライバー。例えば、org.apache.derby.jdbc.EmbeddedDriver です。
openjpa.ConnectionURL JDBC URL。例) jdbc:derby:C:¥¥mysample CREDITREPORT
openjpa.jdbc.SynchronizeMappings JPA 固有プロパティー。例) buildSchema
openjpa.ConnectionUserName データベースのユーザー ID。例) Myid
openjpa.ConnectionPassword ユーザー・パスワード。例) mypwd.
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 an JPQL query that will
	 * retrieve previously unprocessed records. 
	 * Typically the restart token would be 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="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<prop name="openjpa.ConnectionURL" value="jdbc:derby:/opt/tmp/hellojpadb;create=true"/>
<prop name="openjpa.ConnectionUserName" value="" />
<prop name="openjpa.ConnectionPassword" value="" />
<prop name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
<prop name="openjpa.Log" value="DefaultLevel=WARN,SQL=TRACE"/>
<prop name="PERSISTENT_UNIT" value="hellojpa"/>
<prop name="debug" value="true"/>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.samples.JPAOutputStream"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.LocalJDBCReader</impl-class>  
</bds>
</batch-data-streams>	        



関連概念
バッチ・データ・ストリームのフレームワークとパターン
関連情報
JDBCReaderPattern
ByteWriterPattern
FileReaderPattern
FileWriterPattern
JPAWriterPattern
RecordOrientedDatasetReaderPattern


ご利用条件 | フィードバック

最終更新: 2009/09/17 16時38分56秒EDT
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1m1/index.jsp?topic=/com.ibm.websphere.gridmgr.doc/info/scheduler/rbtchpttrn9.html