BATCH-1651: add paging reader to jdbc partitioning sample
This commit is contained in:
@@ -6,6 +6,7 @@ batch.jdbc.user=app
|
||||
batch.jdbc.password=
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.jdbc.verifyCursorPosition=false
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-derby.sql
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-derby.sql
|
||||
batch.business.schema.script=business-schema-derby.sql
|
||||
@@ -14,4 +15,5 @@ batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.De
|
||||
batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=false
|
||||
@@ -6,6 +6,7 @@ batch.jdbc.user=sa
|
||||
batch.jdbc.password=
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.jdbc.verifyCursorPosition=true
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-h2.sql
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-h2.sql
|
||||
batch.business.schema.script=classpath:/business-schema-h2.sql
|
||||
@@ -14,4 +15,5 @@ batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.H2
|
||||
batch.database.incrementer.parent=sequenceIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
@@ -9,6 +9,7 @@ batch.jdbc.user=sa
|
||||
batch.jdbc.password=
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.jdbc.verifyCursorPosition=true
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-hsqldb.sql
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-hsqldb.sql
|
||||
batch.business.schema.script=classpath:/business-schema-hsqldb.sql
|
||||
@@ -16,5 +17,6 @@ batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer
|
||||
batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.grid.size=6
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
@@ -6,6 +6,7 @@ batch.jdbc.user=test
|
||||
batch.jdbc.password=test
|
||||
batch.jdbc.testWhileIdle=true
|
||||
batch.jdbc.validationQuery=SELECT 1
|
||||
batch.jdbc.verifyCursorPosition=true
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-mysql.sql
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-mysql.sql
|
||||
batch.business.schema.script=classpath:business-schema-mysql.sql
|
||||
@@ -13,5 +14,6 @@ batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer
|
||||
batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.jdbc.pool.size=6
|
||||
batch.grid.size=50
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
@@ -6,6 +6,7 @@ batch.jdbc.user=spring
|
||||
batch.jdbc.password=spring
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.jdbc.verifyCursorPosition=true
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-oracle10g.sql
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-oracle10g.sql
|
||||
batch.business.schema.script=business-schema-oracle10g.sql
|
||||
@@ -14,4 +15,5 @@ batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.Or
|
||||
batch.database.incrementer.parent=sequenceIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.OracleLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
@@ -6,6 +6,7 @@ batch.jdbc.user=sa
|
||||
batch.jdbc.password=sa
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.jdbc.verifyCursorPosition=true
|
||||
batch.drop.script=/org/springframework/batch/core/schema-drop-sqlserver.sql
|
||||
batch.schema.script=/org/springframework/batch/core/schema-sqlserver.sql
|
||||
batch.business.schema.script=business-schema-sqlserver.sql
|
||||
@@ -14,4 +15,5 @@ batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.Sq
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
@@ -4,15 +4,17 @@ batch.jdbc.driver=net.sourceforge.jtds.jdbc.Driver
|
||||
batch.jdbc.url=jdbc:jtds:sybase://dbhost:5000;databaseName=test
|
||||
batch.jdbc.user=spring
|
||||
batch.jdbc.password=spring
|
||||
batch.schema=
|
||||
batch.jndi.name=
|
||||
batch.naming.factory.initial=
|
||||
batch.naming.provider.url=
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.jdbc.verifyCursorPosition=true
|
||||
batch.drop.script=/org/springframework/batch/core/schema-drop-sybase.sql
|
||||
batch.schema.script=/org/springframework/batch/core/schema-sybase.sql
|
||||
batch.business.schema.script=business-schema-sybase.sql
|
||||
batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.jdbc.pool.size=6
|
||||
batch.grid.size=6
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
# Bean Properties for override
|
||||
# when not using sequences:
|
||||
incrementerParent.columnName=ID
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<property name="url" value="${batch.jdbc.url}" />
|
||||
<property name="username" value="${batch.jdbc.user}" />
|
||||
<property name="password" value="${batch.jdbc.password}" />
|
||||
<property name="maxActive" value="${batch.jdbc.pool.size}"/>
|
||||
<property name="validationQuery" value="${batch.jdbc.validationQuery}"/>
|
||||
<property name="testWhileIdle" value="${batch.jdbc.testWhileIdle}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" lazy-init="true">
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<bean id="itemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="sql" value="select ID, NAME, CREDIT from CUSTOMER"/>
|
||||
<property name="verifyCursorPosition" value="${batch.jdbc.verifyCursorPosition}"/>
|
||||
<property name="rowMapper">
|
||||
<bean class="org.springframework.batch.sample.domain.trade.internal.CustomerCreditRowMapper"/>
|
||||
</property>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<job id="partitionJdbcJob" xmlns="http://www.springframework.org/schema/batch">
|
||||
<step id="step">
|
||||
<partition step="step1" partitioner="partitioner">
|
||||
<handler grid-size="2" task-executor="taskExecutor"/>
|
||||
<handler grid-size="${batch.grid.size}" task-executor="taskExecutor"/>
|
||||
</partition>
|
||||
</step>
|
||||
</job>
|
||||
@@ -19,7 +19,7 @@
|
||||
<property name="column" value="ID" />
|
||||
</bean>
|
||||
|
||||
<bean id="taskExecutor" class="org.springframework.core.task.SyncTaskExecutor" />
|
||||
<bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
|
||||
|
||||
<step id="step1" xmlns="http://www.springframework.org/schema/batch">
|
||||
<tasklet>
|
||||
@@ -34,24 +34,25 @@
|
||||
<property name="path" value="file:./target/output/jdbc/" />
|
||||
</bean>
|
||||
|
||||
<bean id="itemReader" scope="step" autowire-candidate="false" parent="itemReaderParent">
|
||||
<property name="sql">
|
||||
<value>
|
||||
<![CDATA[
|
||||
select ID,NAME,CREDIT from CUSTOMER where ID >= ? and ID <= ?
|
||||
]]>
|
||||
</value>
|
||||
<bean id="itemReader" scope="step" autowire-candidate="false" class="org.springframework.batch.item.database.JdbcPagingItemReader">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="rowMapper">
|
||||
<bean class="org.springframework.batch.sample.domain.trade.internal.CustomerCreditRowMapper" />
|
||||
</property>
|
||||
<property name="preparedStatementSetter">
|
||||
<bean class="org.springframework.batch.core.resource.ListPreparedStatementSetter">
|
||||
<property name="parameters">
|
||||
<list>
|
||||
<value>#{stepExecutionContext[minValue]}</value>
|
||||
<value>#{stepExecutionContext[maxValue]}</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="queryProvider">
|
||||
<bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="fromClause" value="CUSTOMER"/>
|
||||
<property name="selectClause" value="ID,NAME,CREDIT"/>
|
||||
<property name="sortKey" value="ID"/>
|
||||
<property name="whereClause" value="ID >= :minId and ID <= :maxId"/>
|
||||
</bean>
|
||||
|
||||
</property>
|
||||
<property name="parameterValues">
|
||||
<map>
|
||||
<entry key="minId" value="#{stepExecutionContext[minValue]}"/>
|
||||
<entry key="maxId" value="#{stepExecutionContext[maxValue]}"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
@@ -78,7 +79,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="inputTestReader" parent="itemReaderParent">
|
||||
<bean id="inputTestReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
|
||||
<property name="sql">
|
||||
<value>
|
||||
<![CDATA[
|
||||
@@ -86,10 +87,8 @@
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="itemReaderParent" class="org.springframework.batch.item.database.JdbcCursorItemReader" abstract="true">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="verifyCursorPosition" value="${batch.jdbc.verifyCursorPosition}"/>
|
||||
<property name="rowMapper">
|
||||
<bean class="org.springframework.batch.sample.domain.trade.internal.CustomerCreditRowMapper" />
|
||||
</property>
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/partitionFileJob.xml",
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/partitionJdbcJob.xml",
|
||||
"/job-runner-context.xml" })
|
||||
public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user