From 0d7bf2cd71328082578e7b2185cb50e05e3e01f6 Mon Sep 17 00:00:00 2001 From: wxlund Date: Mon, 17 Dec 2012 16:34:38 -0800 Subject: [PATCH] Modified core to support drop and schema-sqlf.sql but leverages derby syntax outside of connection string. Modified *.properties file to add additional property "batch.isolationlevel=ISOLATION_SERIALIZABLE because batch-sqlf.properties needs batch.isolationlevel=ISOLATION_READ_COMMITTED. Added corresponding sqlf properties and sqlf files. Modified simple-job-launcher-context.xml to support the p:isolationLevelForCreate="${batch.isolationlevel}" --- .../batch/core/schema-drop-sqlf.sql | 12 +++ .../batch/core/schema-sqlf.sql | 79 ++++++++++++++ spring-batch-samples/pom.xml | 5 + .../src/main/resources/batch-derby.properties | 3 +- .../src/main/resources/batch-h2.properties | 1 + .../src/main/resources/batch-hsql.properties | 2 + .../src/main/resources/batch-mysql.properties | 2 + .../main/resources/batch-oracle.properties | 2 + .../src/main/resources/batch-sqlf.properties | 20 ++++ .../main/resources/batch-sqlserver.properties | 2 + .../main/resources/batch-sybase.properties | 2 + .../main/resources/business-schema-sqlf.sql | 100 ++++++++++++++++++ .../resources/simple-job-launcher-context.xml | 3 +- 13 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql create mode 100644 spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql create mode 100644 spring-batch-samples/src/main/resources/batch-sqlf.properties create mode 100644 spring-batch-samples/src/main/resources/business-schema-sqlf.sql diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql new file mode 100644 index 000000000..68ffb0214 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql @@ -0,0 +1,12 @@ +-- Autogenerated: do not edit this file + +DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ; +DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ; +DROP TABLE BATCH_STEP_EXECUTION ; +DROP TABLE BATCH_JOB_EXECUTION ; +DROP TABLE BATCH_JOB_PARAMS ; +DROP TABLE BATCH_JOB_INSTANCE ; + +DROP TABLE BATCH_STEP_EXECUTION_SEQ ; +DROP TABLE BATCH_JOB_EXECUTION_SEQ ; +DROP TABLE BATCH_JOB_SEQ ; diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql new file mode 100644 index 000000000..f52f984fe --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql @@ -0,0 +1,79 @@ +-- Autogenerated: do not edit this file + +CREATE TABLE BATCH_JOB_INSTANCE ( + JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + 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 NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + 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(100) , + 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 NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + 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(100) , + 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 CLOB , + 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 CLOB , + constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID) + references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) +) ; + +CREATE TABLE BATCH_STEP_EXECUTION_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1)); +CREATE TABLE BATCH_JOB_EXECUTION_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1)); +CREATE TABLE BATCH_JOB_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1)); diff --git a/spring-batch-samples/pom.xml b/spring-batch-samples/pom.xml index c44444cb9..558267338 100644 --- a/spring-batch-samples/pom.xml +++ b/spring-batch-samples/pom.xml @@ -17,6 +17,11 @@ hsql + + com.vmware.sqlfire + sqlfireclient + 1.0.3 + org.springframework.batch spring-batch-core diff --git a/spring-batch-samples/src/main/resources/batch-derby.properties b/spring-batch-samples/src/main/resources/batch-derby.properties index 97302789d..385ec9ca5 100644 --- a/spring-batch-samples/src/main/resources/batch-derby.properties +++ b/spring-batch-samples/src/main/resources/batch-derby.properties @@ -14,4 +14,5 @@ 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 \ No newline at end of file +batch.verify.cursor.position=false +batch.isolationlevel=ISOLATION_SERIALIZABLE diff --git a/spring-batch-samples/src/main/resources/batch-h2.properties b/spring-batch-samples/src/main/resources/batch-h2.properties index f8cedeb70..925428ced 100644 --- a/spring-batch-samples/src/main/resources/batch-h2.properties +++ b/spring-batch-samples/src/main/resources/batch-h2.properties @@ -15,3 +15,4 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler batch.grid.size=2 batch.jdbc.pool.size=6 batch.verify.cursor.position=true +batch.isolationlevel=ISOLATION_SERIALIZABLE diff --git a/spring-batch-samples/src/main/resources/batch-hsql.properties b/spring-batch-samples/src/main/resources/batch-hsql.properties index b4ca5b5b3..41423fa1d 100644 --- a/spring-batch-samples/src/main/resources/batch-hsql.properties +++ b/spring-batch-samples/src/main/resources/batch-hsql.properties @@ -18,3 +18,5 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler batch.jdbc.pool.size=6 batch.grid.size=6 batch.verify.cursor.position=true +batch.isolationlevel=ISOLATION_SERIALIZABLE + diff --git a/spring-batch-samples/src/main/resources/batch-mysql.properties b/spring-batch-samples/src/main/resources/batch-mysql.properties index a39515564..947c24b7b 100644 --- a/spring-batch-samples/src/main/resources/batch-mysql.properties +++ b/spring-batch-samples/src/main/resources/batch-mysql.properties @@ -15,3 +15,5 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler batch.jdbc.pool.size=6 batch.grid.size=50 batch.verify.cursor.position=true +batch.isolationlevel=ISOLATION_SERIALIZABLE + diff --git a/spring-batch-samples/src/main/resources/batch-oracle.properties b/spring-batch-samples/src/main/resources/batch-oracle.properties index 811284365..22c75d505 100644 --- a/spring-batch-samples/src/main/resources/batch-oracle.properties +++ b/spring-batch-samples/src/main/resources/batch-oracle.properties @@ -15,3 +15,5 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.OracleLobHandler batch.grid.size=2 batch.jdbc.pool.size=6 batch.verify.cursor.position=true +batch.isolationlevel=ISOLATION_SERIALIZABLE + diff --git a/spring-batch-samples/src/main/resources/batch-sqlf.properties b/spring-batch-samples/src/main/resources/batch-sqlf.properties new file mode 100644 index 000000000..f47ecf9d1 --- /dev/null +++ b/spring-batch-samples/src/main/resources/batch-sqlf.properties @@ -0,0 +1,20 @@ +# Placeholders batch.* +# for Derby: +batch.jdbc.driver=com.vmware.sqlfire.jdbc.ClientDriver +batch.jdbc.url=jdbc:sqlfire://localhost:1257/;update=true +batch.jdbc.user=SAMPLES +batch.jdbc.password=SAMPLES +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-sqlf.sql +batch.business.schema.script=business-schema-sqlf.sql +batch.data.source.init=true +batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer +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 +batch.isolationlevel=ISOLATION_READ_COMMITTED \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/batch-sqlserver.properties b/spring-batch-samples/src/main/resources/batch-sqlserver.properties index a79606c7f..f6307adf9 100644 --- a/spring-batch-samples/src/main/resources/batch-sqlserver.properties +++ b/spring-batch-samples/src/main/resources/batch-sqlserver.properties @@ -15,3 +15,5 @@ batch.database.incrementer.parent=columnIncrementerParent batch.grid.size=2 batch.jdbc.pool.size=6 batch.verify.cursor.position=true +batch.isolationlevel=ISOLATION_SERIALIZABLE + diff --git a/spring-batch-samples/src/main/resources/batch-sybase.properties b/spring-batch-samples/src/main/resources/batch-sybase.properties index 922ba570c..706bc4c62 100644 --- a/spring-batch-samples/src/main/resources/batch-sybase.properties +++ b/spring-batch-samples/src/main/resources/batch-sybase.properties @@ -15,4 +15,6 @@ batch.database.incrementer.parent=columnIncrementerParent batch.jdbc.pool.size=6 batch.grid.size=6 batch.verify.cursor.position=true +batch.isolationlevel=ISOLATION_SERIALIZABLE + diff --git a/spring-batch-samples/src/main/resources/business-schema-sqlf.sql b/spring-batch-samples/src/main/resources/business-schema-sqlf.sql new file mode 100644 index 000000000..027892559 --- /dev/null +++ b/spring-batch-samples/src/main/resources/business-schema-sqlf.sql @@ -0,0 +1,100 @@ +-- Autogenerated: do not edit this file +-- You might need to remove this section the first time you run against a clean database +DROP TABLE BATCH_STAGING_SEQ ; +DROP TABLE TRADE_SEQ ; +DROP TABLE CUSTOMER_SEQ ; +DROP TABLE BATCH_STAGING ; +DROP TABLE TRADE ; +DROP TABLE CUSTOMER ; +DROP TABLE PLAYERS ; +DROP TABLE GAMES ; +DROP TABLE PLAYER_SUMMARY ; +DROP TABLE ERROR_LOG ; + +-- Autogenerated: do not edit this file + +CREATE TABLE CUSTOMER_SEQ (ID BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (start with 5), DUMMY VARCHAR(1)); +CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (start with 0), DUMMY VARCHAR(1)); +CREATE TABLE TRADE_SEQ (ID BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (start with 0), DUMMY VARCHAR(1)); + +CREATE TABLE BATCH_STAGING ( + ID BIGINT NOT NULL PRIMARY KEY, + JOB_ID BIGINT NOT NULL, + VALUE BLOB NOT NULL, + PROCESSED CHAR(1) NOT NULL +) ; + +CREATE TABLE TRADE ( + ID BIGINT 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 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); + +--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (0, 'customer1', 100000); +--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (0, 'customer2', 100000); +--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (0, 'customer3', 100000); +--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (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/simple-job-launcher-context.xml b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml index 6f0fd01f9..147ae9dd2 100644 --- a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml @@ -19,7 +19,8 @@