diff --git a/docs/src/site/docbook/reference/schema-appendix.xml b/docs/src/site/docbook/reference/schema-appendix.xml index 871a731d0..475a4cf60 100644 --- a/docs/src/site/docbook/reference/schema-appendix.xml +++ b/docs/src/site/docbook/reference/schema-appendix.xml @@ -1,6 +1,6 @@ - + Meta-Data Schema @@ -13,25 +13,29 @@ BATCH_JOB_INSTANCE, BATCH_JOB_EXECUTION, BATCH_JOB_PARAMS, BATCH_STEP_EXECUTION, BATCH_STEP_EXECUTION_CONTEXT, respectively. The JobRepository is responsible for saving and storing - each of java object into it's correct table. The following appendix - describes the meta-data tables in detail, along with many of the design - decisions that were made when creating them. When viewing the various - table creation statements below, it is important to realize that the - datatypes used are as generic as possible. Spring Batch provides many - schemas as examples, which all have varying datatypes due to quirks in - individual database vendors' handling of data types. Below is an ERD model - of all 5 tables and their relationships to one another: + each Java object into it's correct table. The following appendix describes + the meta-data tables in detail, along with many of the design decisions + that were made when creating them. When viewing the various table creation + statements below, it is important to realize that the data types used are + as generic as possible. Spring Batch provides many schemas as examples, + which all have varying data types due to variations in individual database + vendors' handling of data types. Below is an ERD model of all 5 tables and + their relationships to one another: - - + + + + + +
Version - Many of the databse tables discussed in this appendix contain a + Many of the database tables discussed in this appendix contain a version column. This column is important because Spring Batch employs an optimistic locking strategy when dealing with updates to the database. This means that each time a record is 'touched' (updated) the value in @@ -39,7 +43,7 @@ to try and save the value, if the version number has change it will throw OptimisticLockingFailureException, indicating there has been an error with concurrent access. This check is - very necessary, since even though different batch jobs may be running in + necessary, since even though different batch jobs may be running in different machines, they are all using the same database tables.
@@ -51,7 +55,7 @@ respective tables. However, they are not database generated keys, but rather are generated by separate sequences. This is necessary because after inserting one of the domain objects into the database, the key it - is given need to be set on the actual object, so that they can be + is given needs to be set on the actual object, so that they can be uniquely identified in Java. Newer database drivers (Jdbc 3.0 and up) support this feature with database generated keys, but rather than requiring it, sequences were used. Each variation of the schema will @@ -61,8 +65,8 @@ CREATE SEQUENCE BATCH_JOB_EXECUTION_SEQ; CREATE SEQUENCE BATCH_JOB_SEQ; - Many database vendors don't official support sequences. In these - cases, work arounds are used, such as the following for mySQL: + Many database vendors don't support sequences. In these cases, + work arounds are used, such as the following for mySQL: CREATE TABLE BATCH_STEP_EXECUTION_SEQ (ID BIGINT NOT NULL) type=MYISAM; INSERT INTO BATCH_STEP_EXECUTION_SEQ values(0); @@ -73,7 +77,7 @@ INSERT INTO BATCH_JOB_SEQ values(0); In the above case, a table is used in place of each sequence. The Spring core class MySQLMaxValueIncrementer will - then increment hte one column in this sequence in order to give similar + then increment the one column in this sequence in order to give similar functionality. @@ -83,7 +87,7 @@ INSERT INTO BATCH_JOB_SEQ values(0); The BATCH_JOB_INSTANCE table holds all information relevant to a JobInstance, and serves as the top of the overall - heirarchy. The following generic DDL statement is used to create + hierarchy. The following generic DDL statement is used to create it: CREATE TABLE BATCH_JOB_INSTANCE ( @@ -156,12 +160,12 @@ INSERT INTO BATCH_JOB_SEQ values(0); TYPE_CD: String representation of the type of value stored, - which can be either a character string, date, long, or double. Because - the type must be known, it cannot be null. + which can be either a string, date, long, or double. Because the type + must be known, it cannot be null. - KEY_NAME: The Parameter key. + KEY_NAME: The parameter key. @@ -177,7 +181,7 @@ INSERT INTO BATCH_JOB_SEQ values(0); - DOUBLE_VAL: Paramter value, if the type is double. + DOUBLE_VAL: Parameter value, if the type is double. @@ -214,8 +218,8 @@ INSERT INTO BATCH_JOB_SEQ values(0); JOB_EXECUTION_ID: Primary key that uniquely identifies this - execution. The value of this column should be obtainable by calling - the getId method of the + execution. The value of this column is obtainable by calling the + getId method of the JobExecution object. @@ -347,7 +351,7 @@ INSERT INTO BATCH_JOB_SEQ values(0); - ITEM_COUNT: The number of items that have been writtne out + ITEM_COUNT: The number of items that have been written out during this execution. @@ -378,10 +382,10 @@ INSERT INTO BATCH_JOB_SEQ values(0); one ExecutionContext per StepExecution, and it contains all user defined key/value pairs that need to persisted for a particular job run. This data - is usually state information that must be retrieved back after a failure - so that a JobInstance can 'start from where it left off'. As with the - BATCH_JOB_PARAMS table, this table has been denormalized and uses a column - to determine the type: + is typically state that must be retrieved back after a failure so that a + JobInstance can 'start from where it left off'. As + with the BATCH_JOB_PARAMS table, this table has been denormalized and uses + a column to determine the type: CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT ( STEP_EXECUTION_ID BIGINT NOT NULL , @@ -429,7 +433,7 @@ INSERT INTO BATCH_JOB_SEQ values(0); - DOUBLE_VAL: Paramter value, if the type is double. + DOUBLE_VAL: Parameter value, if the type is double. @@ -445,4 +449,31 @@ INSERT INTO BATCH_JOB_SEQ values(0); it. If a user so chooses, one may be added with a database generated key, without causing any issues to the framework itself. + +
+ Archiving + + Because there are entries in multiple tables everytime a batch job + is run, it is common to create an archive strategy for the meta-data + tables. The tables themselves are designed to show a record of what + happened in the past, and generally won't affect the run of any job, with + a couple of notable exceptions: + + + + Restart: Because the ExecutionContext is persisted, removing any + entries from this table of jobs that haven't completed successfully, + will prevent them from starting at the correct point if run again. + Furthermore, if an entry for a JobInstance is removed without having + completed successfully, the framework will think that the job is new, + rather than a restart. + + + + Determining if an instance has been run: The framework will use + the meta-data tables to determine if a particular JobInstance has been + run before, and if it has an exception will be thrown. + + +
\ No newline at end of file diff --git a/docs/src/site/resources/reference/images/meta-data-erd.png b/docs/src/site/resources/reference/images/meta-data-erd.png new file mode 100755 index 000000000..2a7179068 Binary files /dev/null and b/docs/src/site/resources/reference/images/meta-data-erd.png differ