WebSphere Extended Deployment Compute Grid, Version 6.1.1
             Operating Systems: AIX, HP-UX, Linux, Solaris, Windows, z/OS


JPAWriterPattern

This pattern is used to write data to a database using a Java Persistence API (JPA) connection.

Supporting classes

  1. JPAWriter: The JPA writer does not participate in the global transaction. However, JPA commits are performed in synchronization with global commits. Future versions will support managed transactions in the presence of EJB 3.0 feature pack.

Required properties

Table 1. Required properties
Property Value
PATTERN_IMPL_CLASS Class implementing JPAWriterPattern interface
openjpa.ConnectionDriverName The JDBC driver. For example, org.apache.derby.jdbc.EmbeddedDriver
openjpa.ConnectionURL The JDBC URL. For example, jdbc:derby:C:\\mysample CREDITREPORT
openjpa.jdbc.SynchronizeMappings JPA specific property. For example, buildSchema
openjpa.ConnectionUserName The user ID for the database. For example, Myid
openjpa.ConnectionPassword User password. For example, mypwd.
PERSISTENT_UNIT The OpenJPA persistent unit name.

Optional properties

Table 2. Optional properties
Property name Value Description

debug

true or false (default is false)

Enables detailed tracing on this batch data stream.

openjpa.Log

DefaultLevel=WARN,SQL=TRACE

JPA log settings

EnablePerformanceMeasurement

true or false (default is false)

Calculates the total time spent in the batch data-streams and the processRecord method, if you are using the GenericXDBatchStep.

Interface definition

public interface JPAWriterPattern {

	/**
	 * This method is invoked during create job step to allow the JPAWriter stream to
	 * initialize. 
	 * @param props Properties passed via xJCL 
	 */
public void initialize(Properties props);
	
	/**
	 * This method is invoked to actually persist the passed object to the database
	 * using JPA EntityManager 
	 * @param manager
	 * @param record
	 */
	public void writeRecord(EntityManager manager, Object record);
}  

xJCL example

<batch-data-streams> 
<bds>  
<logical-name>outputStream</logical-name>  
<props>  
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoWriter"/>  
<prop name="jdbc_url" value="jdbc:derby:C:\\mysample\\CREDITREPORT"/>  
<prop name="jdbc_driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>  
<prop name="user_id" value="myuserid"/>  
<prop name="pswd" value="mypswd"/>  
<prop name="debug" value="true"/>  
</props>  
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.LocalJDBCWriter</impl-class>  
</bds>  
</batch-data-streams> 



Related concepts
Batch data stream framework and patterns
Related tasks
[For z/OS operating system] Using the batch data stream (BDS) framework
Related information
JDBCReaderPattern
JPAReaderPattern
[For z/OS operating system] ByteReaderPattern
ByteWriterPattern
FileReaderPattern
FileWriterPattern
RecordOrientedDatasetReaderPattern
[For z/OS operating system] RecordOrientedDataSetWriterPattern


Terms of Use | Feedback

Last updated: Oct 30, 2009 1:38:02 PM EDT
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1m1/index.jsp?topic=/com.ibm.websphere.gridmgr.doc/info/scheduler/rbtchpttrn10.html