diff --git a/spring-batch-core/pom.xml b/spring-batch-core/pom.xml
index 18b70aa09..e02738d4d 100644
--- a/spring-batch-core/pom.xml
+++ b/spring-batch-core/pom.xml
@@ -168,6 +168,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-h2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-h2.sql
new file mode 100644
index 000000000..03af4f3c6
--- /dev/null
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-h2.sql
@@ -0,0 +1,12 @@
+-- Autogenerated: do not edit this file
+
+DROP TABLE BATCH_STEP_EXECUTION_CONTEXT IF EXISTS;
+DROP TABLE BATCH_JOB_EXECUTION_CONTEXT IF EXISTS;
+DROP TABLE BATCH_STEP_EXECUTION IF EXISTS;
+DROP TABLE BATCH_JOB_EXECUTION IF EXISTS;
+DROP TABLE BATCH_JOB_PARAMS IF EXISTS;
+DROP TABLE BATCH_JOB_INSTANCE IF EXISTS;
+
+DROP SEQUENCE BATCH_STEP_EXECUTION_SEQ IF EXISTS;
+DROP SEQUENCE BATCH_JOB_EXECUTION_SEQ IF EXISTS;
+DROP SEQUENCE BATCH_JOB_SEQ IF EXISTS;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql
new file mode 100644
index 000000000..e87bbb6a8
--- /dev/null
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql
@@ -0,0 +1,79 @@
+-- Autogenerated: do not edit this file
+
+CREATE TABLE BATCH_JOB_INSTANCE (
+ JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_KEY VARCHAR(32) NOT NULL,
+ constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
+) ;
+
+CREATE TABLE BATCH_JOB_EXECUTION (
+ JOB_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_INSTANCE_ID BIGINT NOT NULL,
+ CREATE_TIME TIMESTAMP NOT NULL,
+ START_TIME TIMESTAMP DEFAULT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
+ STATUS VARCHAR(10) ,
+ EXIT_CODE VARCHAR(20) ,
+ EXIT_MESSAGE VARCHAR(2500) ,
+ LAST_UPDATED TIMESTAMP,
+ constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
+ references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+) ;
+
+CREATE TABLE BATCH_JOB_PARAMS (
+ JOB_INSTANCE_ID BIGINT NOT NULL ,
+ TYPE_CD VARCHAR(6) NOT NULL ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
+ DATE_VAL TIMESTAMP DEFAULT NULL ,
+ LONG_VAL BIGINT ,
+ DOUBLE_VAL DOUBLE PRECISION ,
+ constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
+ references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+) ;
+
+CREATE TABLE BATCH_STEP_EXECUTION (
+ STEP_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT NOT NULL,
+ STEP_NAME VARCHAR(100) NOT NULL,
+ JOB_EXECUTION_ID BIGINT NOT NULL,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
+ STATUS VARCHAR(10) ,
+ COMMIT_COUNT BIGINT ,
+ READ_COUNT BIGINT ,
+ FILTER_COUNT BIGINT ,
+ WRITE_COUNT BIGINT ,
+ READ_SKIP_COUNT BIGINT ,
+ WRITE_SKIP_COUNT BIGINT ,
+ PROCESS_SKIP_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
+ EXIT_CODE VARCHAR(20) ,
+ EXIT_MESSAGE VARCHAR(2500) ,
+ LAST_UPDATED TIMESTAMP,
+ constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
+) ;
+
+CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
+ STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
+ SHORT_CONTEXT VARCHAR(2500) NOT NULL,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
+ constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
+ references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
+) ;
+
+CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
+ JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
+ SHORT_CONTEXT VARCHAR(2500) NOT NULL,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
+ constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
+) ;
+
+CREATE SEQUENCE BATCH_STEP_EXECUTION_SEQ;
+CREATE SEQUENCE BATCH_JOB_EXECUTION_SEQ;
+CREATE SEQUENCE BATCH_JOB_SEQ;
diff --git a/spring-batch-core/src/main/sql/h2.properties b/spring-batch-core/src/main/sql/h2.properties
new file mode 100644
index 000000000..76afa046f
--- /dev/null
+++ b/spring-batch-core/src/main/sql/h2.properties
@@ -0,0 +1,12 @@
+platform=h2
+# SQL language oddities
+BIGINT = BIGINT
+IDENTITY = IDENTITY
+IFEXISTS = IF EXISTS
+DOUBLE = DOUBLE PRECISION
+BLOB = LONGVARBINARY
+CLOB = LONGVARCHAR
+TIMESTAMP = TIMESTAMP
+VARCHAR = VARCHAR
+# for generating drop statements...
+SEQUENCE = SEQUENCE
diff --git a/spring-batch-core/src/main/sql/h2.vpp b/spring-batch-core/src/main/sql/h2.vpp
new file mode 100644
index 000000000..55aee40c3
--- /dev/null
+++ b/spring-batch-core/src/main/sql/h2.vpp
@@ -0,0 +1,3 @@
+#macro (sequence $name)CREATE SEQUENCE ${name};
+#end
+#macro (notnull $name $type)ALTER COLUMN ${name} ${type} NOT NULL#end
diff --git a/spring-batch-core/src/main/sql/oracle10g.vpp b/spring-batch-core/src/main/sql/oracle10g.vpp
index 43fd38da0..7efe8f319 100644
--- a/spring-batch-core/src/main/sql/oracle10g.vpp
+++ b/spring-batch-core/src/main/sql/oracle10g.vpp
@@ -1,3 +1,3 @@
-#macro (sequence $name)CREATE SEQUENCE ${name} MAXVALUE 9223372036854775807 NOCYCLE;
+#macro (sequence $name)CREATE SEQUENCE ${name} START WITH ${value} MAXVALUE 9223372036854775807 NOCYCLE;
#end
#macro (notnull $name $type)MODIFY ${name} NOT NULL#end
diff --git a/spring-batch-infrastructure/pom.xml b/spring-batch-infrastructure/pom.xml
index a5237b224..e9899a6af 100644
--- a/spring-batch-infrastructure/pom.xml
+++ b/spring-batch-infrastructure/pom.xml
@@ -88,6 +88,11 @@
commons-io
test
+
+ commons-dbcp
+ commons-dbcp
+ test
+
org.codehaus.jackson
jackson-mapper-asl
@@ -99,6 +104,11 @@
hsqldb
test
+
+ com.h2database
+ h2
+ test
+
org.hibernate
hibernate-core
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java
index f05986ecb..92d046a25 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java
@@ -18,6 +18,7 @@ package org.springframework.batch.item.database.support;
import static org.springframework.batch.support.DatabaseType.DB2;
import static org.springframework.batch.support.DatabaseType.DB2ZOS;
import static org.springframework.batch.support.DatabaseType.DERBY;
+import static org.springframework.batch.support.DatabaseType.H2;
import static org.springframework.batch.support.DatabaseType.HSQL;
import static org.springframework.batch.support.DatabaseType.MYSQL;
import static org.springframework.batch.support.DatabaseType.ORACLE;
@@ -35,6 +36,7 @@ import org.springframework.jdbc.support.incrementer.DB2MainframeSequenceMaxValue
import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
+import org.springframework.jdbc.support.incrementer.H2SequenceMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
@@ -86,6 +88,9 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
else if (databaseType == HSQL) {
return new HsqlMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
}
+ else if (databaseType == H2) {
+ return new H2SequenceMaxValueIncrementer(dataSource, incrementerName);
+ }
else if (databaseType == MYSQL) {
return new MySQLMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/H2PagingQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/H2PagingQueryProvider.java
new file mode 100644
index 000000000..712028cb6
--- /dev/null
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/H2PagingQueryProvider.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2006-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.batch.item.database.support;
+
+/**
+ * H2 implementation of a {@link org.springframework.batch.item.database.PagingQueryProvider} using database specific features.
+ *
+ * @author Dave Syer
+ * @since 2.1
+ */
+public class H2PagingQueryProvider extends AbstractSqlPagingQueryProvider {
+
+ @Override
+ public String generateFirstPageQuery(int pageSize) {
+ return SqlPagingQueryUtils.generateTopSqlQuery(this, false, buildTopClause(pageSize));
+ }
+
+ @Override
+ public String generateRemainingPagesQuery(int pageSize) {
+ return SqlPagingQueryUtils.generateTopSqlQuery(this, true, buildTopClause(pageSize));
+ }
+
+ private String buildTopClause(int pageSize) {
+ return new StringBuilder().append("TOP ").append(pageSize).toString();
+ }
+
+ @Override
+ public String generateJumpToItemQuery(int itemIndex, int pageSize) {
+ int page = itemIndex / pageSize;
+ int offset = (page * pageSize) - 1;
+ offset = offset<0 ? 0 : offset;
+
+ String topClause = new StringBuilder().append("LIMIT ").append(offset).append(" 1").toString();
+ return SqlPagingQueryUtils.generateTopJumpToQuery(this, topClause);
+ }
+
+}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java
index a7b419fbc..42ae64509 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java
@@ -19,6 +19,7 @@ import static org.springframework.batch.support.DatabaseType.DB2;
import static org.springframework.batch.support.DatabaseType.DB2ZOS;
import static org.springframework.batch.support.DatabaseType.DERBY;
import static org.springframework.batch.support.DatabaseType.HSQL;
+import static org.springframework.batch.support.DatabaseType.H2;
import static org.springframework.batch.support.DatabaseType.MYSQL;
import static org.springframework.batch.support.DatabaseType.ORACLE;
import static org.springframework.batch.support.DatabaseType.POSTGRES;
@@ -68,6 +69,7 @@ public class SqlPagingQueryProviderFactoryBean implements FactoryBean {
providers.put(DB2ZOS, new Db2PagingQueryProvider());
providers.put(DERBY,new DerbyPagingQueryProvider());
providers.put(HSQL,new HsqlPagingQueryProvider());
+ providers.put(H2,new H2PagingQueryProvider());
providers.put(MYSQL,new MySqlPagingQueryProvider());
providers.put(ORACLE,new OraclePagingQueryProvider());
providers.put(POSTGRES,new PostgresPagingQueryProvider());
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java
index 0953219a5..756e56f5a 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java
@@ -43,7 +43,7 @@ public enum DatabaseType {
MYSQL("MySQL"),
ORACLE("Oracle"),
POSTGRES("PostgreSQL"),
- SYBASE("Sybase");
+ SYBASE("Sybase"), H2("H2");
private static final Map nameMap;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/H2PagingQueryProviderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/H2PagingQueryProviderTests.java
new file mode 100644
index 000000000..6cd942ef3
--- /dev/null
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/H2PagingQueryProviderTests.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.batch.item.database.support;
+
+import org.junit.Test;
+import org.junit.Assert;
+
+/**
+ * @author Thomas Risberg
+ * @author Dave Syer
+ */
+public class H2PagingQueryProviderTests extends AbstractSqlPagingQueryProviderTests {
+
+ public H2PagingQueryProviderTests() {
+ pagingQueryProvider = new H2PagingQueryProvider();
+ }
+
+ @Test
+ @Override
+ public void testGenerateFirstPageQuery() {
+ String sql = "SELECT TOP 100 id, name, age FROM foo WHERE bar = 1 ORDER BY id ASC";
+ String s = pagingQueryProvider.generateFirstPageQuery(pageSize);
+ Assert.assertEquals("", sql, s);
+ }
+
+ @Test @Override
+ public void testGenerateRemainingPagesQuery() {
+ String sql = "SELECT TOP 100 id, name, age FROM foo WHERE bar = 1 AND id > ? ORDER BY id ASC";
+ String s = pagingQueryProvider.generateRemainingPagesQuery(pageSize);
+ Assert.assertEquals("", sql, s);
+ }
+
+ @Test @Override
+ public void testGenerateJumpToItemQuery() {
+ String sql = "SELECT LIMIT 99 1 id AS SORT_KEY FROM foo WHERE bar = 1 ORDER BY id ASC";
+ String s = pagingQueryProvider.generateJumpToItemQuery(145, pageSize);
+ Assert.assertEquals("", sql, s);
+ }
+
+ @Test @Override
+ public void testGenerateJumpToItemQueryForFirstPage() {
+ String sql = "SELECT LIMIT 0 1 id AS SORT_KEY FROM foo WHERE bar = 1 ORDER BY id ASC";
+ String s = pagingQueryProvider.generateJumpToItemQuery(45, pageSize);
+ Assert.assertEquals("", sql, s);
+ }
+}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeIntegrationTests.java
new file mode 100644
index 000000000..ebdacbc7e
--- /dev/null
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeIntegrationTests.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.batch.support;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.sql.DataSource;
+
+import org.junit.Test;
+
+
+/**
+ * @author Dave Syer
+ *
+ */
+public class DatabaseTypeIntegrationTests {
+
+ @Test
+ public void testH2() throws Exception {
+ DataSource dataSource = DatabaseTypeTestUtils.getDataSource(org.h2.jdbc.JdbcConnection.class, "jdbc:h2:file:target/data/sample");
+ assertEquals(DatabaseType.H2, DatabaseType.fromMetaData(dataSource));
+ dataSource.getConnection();
+ }
+
+}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTestUtils.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTestUtils.java
index fe7258c79..fc04c9546 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTestUtils.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTestUtils.java
@@ -24,12 +24,21 @@ import java.sql.DatabaseMetaData;
import javax.sql.DataSource;
+import org.apache.commons.dbcp.BasicDataSource;
+
/**
* @author Dave Syer
*
*/
public class DatabaseTypeTestUtils {
+ public static DataSource getDataSource(Class> driver, String url) throws Exception {
+ BasicDataSource dataSource = new BasicDataSource();
+ dataSource.setDriverClassName(driver.getName());
+ dataSource.setUrl(url);
+ return dataSource;
+ }
+
public static DataSource getMockDataSource() throws Exception {
return getMockDataSource(DatabaseType.HSQL.getProductName());
}
diff --git a/spring-batch-parent/pom.xml b/spring-batch-parent/pom.xml
index 927cda3a5..e533037ec 100644
--- a/spring-batch-parent/pom.xml
+++ b/spring-batch-parent/pom.xml
@@ -1,5 +1,6 @@
-
+
4.0.0
org.springframework.batch
spring-batch-parent
@@ -398,6 +399,12 @@
1.8.0.7
test
+
+ com.h2database
+ h2
+ 1.2.125
+ test
+
org.apache.derby
derby
diff --git a/spring-batch-samples/pom.xml b/spring-batch-samples/pom.xml
index 8f3a77f09..f6e090446 100644
--- a/spring-batch-samples/pom.xml
+++ b/spring-batch-samples/pom.xml
@@ -98,6 +98,11 @@
hsqldb
runtime
+
+ com.h2database
+ h2
+ runtime
+
commons-io
commons-io
@@ -278,6 +283,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-batch-samples/src/main/resources/batch-h2.properties b/spring-batch-samples/src/main/resources/batch-h2.properties
new file mode 100644
index 000000000..6052d1d21
--- /dev/null
+++ b/spring-batch-samples/src/main/resources/batch-h2.properties
@@ -0,0 +1,15 @@
+# Placeholders batch.*
+# for H2:
+batch.jdbc.driver=org.h2.jdbc.JdbcConnection
+batch.jdbc.url=jdbc:h2:file:target/data/h2
+batch.jdbc.user=sa
+batch.jdbc.password=
+batch.jdbc.testWhileIdle=false
+batch.jdbc.validationQuery=
+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
+batch.data.source.init=true
+batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.H2SequenceMaxValueIncrementer
+batch.database.incrementer.parent=sequenceIncrementerParent
+batch.grid.size=2
diff --git a/spring-batch-samples/src/main/resources/batch-oracle.properties b/spring-batch-samples/src/main/resources/batch-oracle.properties
index 4cdd6fec9..6adf754ad 100644
--- a/spring-batch-samples/src/main/resources/batch-oracle.properties
+++ b/spring-batch-samples/src/main/resources/batch-oracle.properties
@@ -4,12 +4,13 @@ batch.jdbc.driver=oracle.jdbc.OracleDriver
batch.jdbc.url=jdbc:oracle:thin:@//dbhost:1521/xe
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.schema.script=/org/springframework/batch/core/schema-oracle10g.sql
batch.business.schema.script=business-schema-oracle10g.sql
+batch.data.source.init=true
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer
+batch.database.incrementer.parent=sequenceIncrementerParent
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
+batch.grid.size=2
diff --git a/spring-batch-samples/src/main/resources/business-schema-db2.sql b/spring-batch-samples/src/main/resources/business-schema-db2.sql
index d203b88fb..753c3eff2 100644
--- a/spring-batch-samples/src/main/resources/business-schema-db2.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-db2.sql
@@ -36,7 +36,7 @@ CREATE TABLE CUSTOMER (
ID BIGINT NOT NULL PRIMARY KEY ,
VERSION BIGINT ,
NAME VARCHAR(45) ,
- CREDIT DECIMAL(8,2)
+ CREDIT DECIMAL(10,2)
) ;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/business-schema-derby.sql b/spring-batch-samples/src/main/resources/business-schema-derby.sql
index 61f36fdb5..3ddc496b0 100644
--- a/spring-batch-samples/src/main/resources/business-schema-derby.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-derby.sql
@@ -13,7 +13,7 @@ DROP TABLE ERROR_LOG ;
-- Autogenerated: do not edit this file
CREATE TABLE CUSTOMER_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
-INSERT INTO CUSTOMER_SEQ (ID) values (4);
+INSERT INTO CUSTOMER_SEQ (ID) values (5);
CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
INSERT INTO BATCH_STAGING_SEQ (ID) values (0);
CREATE TABLE TRADE_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
@@ -39,7 +39,7 @@ CREATE TABLE CUSTOMER (
ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
VERSION BIGINT ,
NAME VARCHAR(45) ,
- CREDIT DECIMAL(8,2)
+ CREDIT DECIMAL(10,2)
) ;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/business-schema-h2.sql b/spring-batch-samples/src/main/resources/business-schema-h2.sql
new file mode 100644
index 000000000..cbe742b01
--- /dev/null
+++ b/spring-batch-samples/src/main/resources/business-schema-h2.sql
@@ -0,0 +1,93 @@
+-- Autogenerated: do not edit this file
+DROP SEQUENCE BATCH_STAGING_SEQ IF EXISTS;
+DROP SEQUENCE TRADE_SEQ IF EXISTS;
+DROP SEQUENCE CUSTOMER_SEQ IF EXISTS;
+DROP TABLE BATCH_STAGING IF EXISTS;
+DROP TABLE TRADE IF EXISTS;
+DROP TABLE CUSTOMER IF EXISTS;
+DROP TABLE PLAYERS IF EXISTS;
+DROP TABLE GAMES IF EXISTS;
+DROP TABLE PLAYER_SUMMARY IF EXISTS;
+DROP TABLE ERROR_LOG IF EXISTS;
+
+-- Autogenerated: do not edit this file
+
+CREATE SEQUENCE CUSTOMER_SEQ START WITH 5;
+CREATE SEQUENCE BATCH_STAGING_SEQ START WITH 0;
+CREATE SEQUENCE TRADE_SEQ START WITH 0;
+
+CREATE TABLE BATCH_STAGING (
+ ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ JOB_ID BIGINT NOT NULL,
+ VALUE LONGVARBINARY NOT NULL,
+ PROCESSED CHAR(1) NOT NULL
+) ;
+
+CREATE TABLE TRADE (
+ ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ ISIN VARCHAR(45) NOT NULL,
+ QUANTITY BIGINT ,
+ PRICE DECIMAL(8,2) ,
+ CUSTOMER VARCHAR(45)
+) ;
+
+CREATE TABLE CUSTOMER (
+ ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ NAME VARCHAR(45) ,
+ CREDIT DECIMAL(10,2)
+) ;
+
+INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
+INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (2, 0, 'customer2', 100000);
+INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (3, 0, 'customer3', 100000);
+INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (4, 0, 'customer4', 100000);
+
+CREATE TABLE PLAYERS (
+ PLAYER_ID CHAR(8) NOT NULL PRIMARY KEY,
+ LAST_NAME VARCHAR(35) NOT NULL,
+ FIRST_NAME VARCHAR(25) NOT NULL,
+ POS VARCHAR(10) ,
+ YEAR_OF_BIRTH BIGINT NOT NULL,
+ YEAR_DRAFTED BIGINT NOT NULL
+) ;
+
+CREATE TABLE GAMES (
+ PLAYER_ID CHAR(8) NOT NULL,
+ YEAR_NO BIGINT NOT NULL,
+ TEAM CHAR(3) NOT NULL,
+ WEEK BIGINT NOT NULL,
+ OPPONENT CHAR(3) ,
+ COMPLETES BIGINT ,
+ ATTEMPTS BIGINT ,
+ PASSING_YARDS BIGINT ,
+ PASSING_TD BIGINT ,
+ INTERCEPTIONS BIGINT ,
+ RUSHES BIGINT ,
+ RUSH_YARDS BIGINT ,
+ RECEPTIONS BIGINT ,
+ RECEPTIONS_YARDS BIGINT ,
+ TOTAL_TD BIGINT
+) ;
+
+CREATE TABLE PLAYER_SUMMARY (
+ ID CHAR(8) NOT NULL,
+ YEAR_NO BIGINT NOT NULL,
+ COMPLETES BIGINT NOT NULL ,
+ ATTEMPTS BIGINT NOT NULL ,
+ PASSING_YARDS BIGINT NOT NULL ,
+ PASSING_TD BIGINT NOT NULL ,
+ INTERCEPTIONS BIGINT NOT NULL ,
+ RUSHES BIGINT NOT NULL ,
+ RUSH_YARDS BIGINT NOT NULL ,
+ RECEPTIONS BIGINT NOT NULL ,
+ RECEPTIONS_YARDS BIGINT NOT NULL ,
+ TOTAL_TD BIGINT NOT NULL
+) ;
+
+CREATE TABLE ERROR_LOG (
+ JOB_NAME CHAR(20) ,
+ STEP_NAME CHAR(20) ,
+ MESSAGE VARCHAR(300) NOT NULL
+) ;
diff --git a/spring-batch-samples/src/main/resources/business-schema-hsqldb.sql b/spring-batch-samples/src/main/resources/business-schema-hsqldb.sql
index 39845bbfa..b02b0b89a 100644
--- a/spring-batch-samples/src/main/resources/business-schema-hsqldb.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-hsqldb.sql
@@ -15,7 +15,7 @@ DROP TABLE ERROR_LOG IF EXISTS;
CREATE TABLE CUSTOMER_SEQ (
ID BIGINT IDENTITY
);
-INSERT INTO CUSTOMER_SEQ (ID) values (4);
+INSERT INTO CUSTOMER_SEQ (ID) values (5);
CREATE TABLE BATCH_STAGING_SEQ (
ID BIGINT IDENTITY
);
@@ -45,7 +45,7 @@ CREATE TABLE CUSTOMER (
ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
VERSION BIGINT ,
NAME VARCHAR(45) ,
- CREDIT DECIMAL(8,2)
+ CREDIT DECIMAL(10,2)
) ;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/business-schema-mysql.sql b/spring-batch-samples/src/main/resources/business-schema-mysql.sql
index 86164e3e9..99fd85c65 100644
--- a/spring-batch-samples/src/main/resources/business-schema-mysql.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-mysql.sql
@@ -13,7 +13,7 @@ DROP TABLE IF EXISTS ERROR_LOG ;
-- Autogenerated: do not edit this file
CREATE TABLE CUSTOMER_SEQ (ID BIGINT NOT NULL) type=MYISAM;
-INSERT INTO CUSTOMER_SEQ values(4);
+INSERT INTO CUSTOMER_SEQ values(5);
CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT NOT NULL) type=MYISAM;
INSERT INTO BATCH_STAGING_SEQ values(0);
CREATE TABLE TRADE_SEQ (ID BIGINT NOT NULL) type=MYISAM;
@@ -39,7 +39,7 @@ CREATE TABLE CUSTOMER (
ID BIGINT NOT NULL PRIMARY KEY ,
VERSION BIGINT ,
NAME VARCHAR(45) ,
- CREDIT DECIMAL(8,2)
+ CREDIT DECIMAL(10,2)
) type=InnoDB;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/business-schema-oracle10g.sql b/spring-batch-samples/src/main/resources/business-schema-oracle10g.sql
index 5e13426aa..47f66092a 100644
--- a/spring-batch-samples/src/main/resources/business-schema-oracle10g.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-oracle10g.sql
@@ -12,9 +12,9 @@ DROP TABLE ERROR_LOG ;
-- Autogenerated: do not edit this file
-CREATE SEQUENCE CUSTOMER_SEQ;
-CREATE SEQUENCE BATCH_STAGING_SEQ;
-CREATE SEQUENCE TRADE_SEQ;
+CREATE SEQUENCE CUSTOMER_SEQ START WITH 5;
+CREATE SEQUENCE BATCH_STAGING_SEQ START WITH 0;
+CREATE SEQUENCE TRADE_SEQ START WITH 0;
CREATE TABLE BATCH_STAGING (
ID NUMBER(38) NOT NULL PRIMARY KEY ,
@@ -36,7 +36,7 @@ CREATE TABLE CUSTOMER (
ID NUMBER(38) NOT NULL PRIMARY KEY ,
VERSION NUMBER(38) ,
NAME VARCHAR2(45) ,
- CREDIT DECIMAL(8,2)
+ CREDIT DECIMAL(10,2)
) ;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/business-schema-postgresql.sql b/spring-batch-samples/src/main/resources/business-schema-postgresql.sql
index 45c373b20..63add0c36 100644
--- a/spring-batch-samples/src/main/resources/business-schema-postgresql.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-postgresql.sql
@@ -36,7 +36,7 @@ CREATE TABLE CUSTOMER (
ID BIGINT NOT NULL PRIMARY KEY ,
VERSION BIGINT ,
NAME VARCHAR(45) ,
- CREDIT DECIMAL(8,2)
+ CREDIT DECIMAL(10,2)
) ;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/business-schema-sqlserver.sql b/spring-batch-samples/src/main/resources/business-schema-sqlserver.sql
index 6b90c2ff6..3ce5065e9 100644
--- a/spring-batch-samples/src/main/resources/business-schema-sqlserver.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-sqlserver.sql
@@ -13,7 +13,7 @@ DROP TABLE ERROR_LOG ;
-- Autogenerated: do not edit this file
CREATE TABLE CUSTOMER_SEQ (ID BIGINT IDENTITY);
-INSERT INTO CUSTOMER_SEQ (ID) values (4);
+INSERT INTO CUSTOMER_SEQ (ID) values (5);
CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT IDENTITY);
INSERT INTO BATCH_STAGING_SEQ (ID) values (0);
CREATE TABLE TRADE_SEQ (ID BIGINT IDENTITY);
@@ -39,7 +39,7 @@ CREATE TABLE CUSTOMER (
ID BIGINT NOT NULL PRIMARY KEY ,
VERSION BIGINT ,
NAME VARCHAR(45) ,
- CREDIT DECIMAL(8,2)
+ CREDIT DECIMAL(10,2)
) ;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/business-schema-sybase.sql b/spring-batch-samples/src/main/resources/business-schema-sybase.sql
index 7400cca1d..f4470c248 100644
--- a/spring-batch-samples/src/main/resources/business-schema-sybase.sql
+++ b/spring-batch-samples/src/main/resources/business-schema-sybase.sql
@@ -13,7 +13,7 @@ DROP TABLE ERROR_LOG ;
-- Autogenerated: do not edit this file
CREATE TABLE CUSTOMER_SEQ (ID BIGINT IDENTITY);
-INSERT INTO CUSTOMER_SEQ (ID) values (4);
+INSERT INTO CUSTOMER_SEQ (ID) values (5);
CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT IDENTITY);
INSERT INTO BATCH_STAGING_SEQ (ID) values (0);
CREATE TABLE TRADE_SEQ (ID BIGINT IDENTITY);
@@ -39,7 +39,7 @@ CREATE TABLE CUSTOMER (
ID BIGINT NOT NULL PRIMARY KEY ,
VERSION BIGINT NULL,
NAME VARCHAR(45) NULL,
- CREDIT DECIMAL(8,2) NULL
+ CREDIT DECIMAL(10,2) NULL
) ;
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/resources/data-source-context.xml b/spring-batch-samples/src/main/resources/data-source-context.xml
index 0604682f4..ae90208ce 100644
--- a/spring-batch-samples/src/main/resources/data-source-context.xml
+++ b/spring-batch-samples/src/main/resources/data-source-context.xml
@@ -17,7 +17,7 @@
-
+
@@ -55,8 +55,11 @@
-
+
+
+
+
diff --git a/spring-batch-samples/src/main/resources/log4j.properties b/spring-batch-samples/src/main/resources/log4j.properties
index d65988c7f..5c28adfd2 100644
--- a/spring-batch-samples/src/main/resources/log4j.properties
+++ b/spring-batch-samples/src/main/resources/log4j.properties
@@ -28,5 +28,6 @@ log4j.appender.chainsaw.layout=org.apache.log4j.xml.XMLLayout
#log4j.logger.org.springframework.orm=debug
### debug your specific package or classes with the following example
+log4j.logger.org.springframework.jdbc=debug
log4j.logger.org.springframework.batch=debug
log4j.logger.org.springframework.batch.sample=debug
diff --git a/spring-batch-samples/src/main/sql/h2.properties b/spring-batch-samples/src/main/sql/h2.properties
new file mode 100644
index 000000000..a613a5aa9
--- /dev/null
+++ b/spring-batch-samples/src/main/sql/h2.properties
@@ -0,0 +1,12 @@
+platform=h2
+# SQL language oddities
+BIGINT = BIGINT
+IDENTITY = IDENTITY
+IFEXISTS = IF EXISTS
+DOUBLE = DOUBLE PRECISION
+DECIMAL = DECIMAL
+BLOB = LONGVARBINARY
+TIMESTAMP = TIMESTAMP
+VARCHAR = VARCHAR
+# for generating drop statements...
+SEQUENCE = SEQUENCE
diff --git a/spring-batch-samples/src/main/sql/h2.vpp b/spring-batch-samples/src/main/sql/h2.vpp
new file mode 100644
index 000000000..36c05ac5e
--- /dev/null
+++ b/spring-batch-samples/src/main/sql/h2.vpp
@@ -0,0 +1,2 @@
+#macro (sequence $name $value)CREATE SEQUENCE ${name} START WITH ${value};
+#end
diff --git a/spring-batch-samples/src/main/sql/init.sql.vpp b/spring-batch-samples/src/main/sql/init.sql.vpp
index af4836a84..07ef51b1b 100644
--- a/spring-batch-samples/src/main/sql/init.sql.vpp
+++ b/spring-batch-samples/src/main/sql/init.sql.vpp
@@ -1,6 +1,6 @@
-- Autogenerated: do not edit this file
-#sequence( "CUSTOMER_SEQ" 4 )
+#sequence( "CUSTOMER_SEQ" 5 )
#sequence( "BATCH_STAGING_SEQ" 0 )
#sequence( "TRADE_SEQ" 0 )
@@ -24,7 +24,7 @@ CREATE TABLE CUSTOMER (
ID ${BIGINT} $!{IDENTITY} NOT NULL PRIMARY KEY $!{GENERATED},
VERSION ${BIGINT} $!{NULL},
NAME ${VARCHAR}(45) $!{NULL},
- CREDIT ${DECIMAL}(8,2) $!{NULL}
+ CREDIT ${DECIMAL}(10,2) $!{NULL}
) $!{VOODOO};
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
diff --git a/spring-batch-samples/src/main/sql/oracle10g.vpp b/spring-batch-samples/src/main/sql/oracle10g.vpp
index 4e1c4bdbb..36c05ac5e 100644
--- a/spring-batch-samples/src/main/sql/oracle10g.vpp
+++ b/spring-batch-samples/src/main/sql/oracle10g.vpp
@@ -1,2 +1,2 @@
-#macro (sequence $name $value)CREATE SEQUENCE ${name};
+#macro (sequence $name $value)CREATE SEQUENCE ${name} START WITH ${value};
#end