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