← All schemas
Schema Library

Spring Batch Metadata Tables Diagram

Spring Batch persists every job run in six metadata tables. BATCH_JOB_INSTANCE is the top of the hierarchy - one row per logical job identified by name plus key. Each run adds a BATCH_JOB_EXECUTION row with status, exit code, and timestamps; parameters land in BATCH_JOB_EXECUTION_PARAMS; each step adds a BATCH_STEP_EXECUTION row with read/write/skip counters; and restart state is serialized into the two _CONTEXT tables. The design detail that surprises people: the _ID primary keys are not database-generated - they come from separate sequences, because the key must be set on the Java object right after insert.

Written by Varun Krishnan · Founder, dbdiagramr

Published · Updated

Source: Official schema-postgresql.sql, Spring Batch v6.0.6 (spring-projects/spring-batch) · License: Apache-2.0

Tables
6
Hierarchy
Instance -> Execution -> Step
Version
6.0.6

Spring Batch 6.0.6 schema-postgresql.sql. The official DDL uses unquoted uppercase names, which PostgreSQL stores in lowercase; this page and its copied DDL use those lowercase names.

The three BATCH_*_SEQ sequences are omitted; the application assigns the IDs before inserting. schema-postgresql.sql v6.0.6.

Spring Batch database schema diagram showing every table, column, and foreign key

Scroll horizontally to see the full diagram. Click it to open at full size.

Open in DBdiagramr to edit →

Embed this diagram

Paste this HTML into a README, docs page, or blog post. The image links back to the full schema page.

<a href="https://www.dbdiagramr.space/schema/spring-batch">
  <img src="https://www.dbdiagramr.space/schemas/spring-batch-er-diagram.svg" alt="Spring Batch Metadata Tables Diagram (PostgreSQL)" width="1318" height="1052" />
</a>
<p><a href="https://www.dbdiagramr.space/schema/spring-batch">Spring Batch Metadata Tables Diagram (PostgreSQL)</a> by dbdiagramr</p>

Tables in the Spring Batch schema

ColumnTypeNullableKey
batch_job_instance
job_instance_idBIGINTNoPK
versionBIGINTYes-
job_nameVARCHAR(100)No-
job_keyVARCHAR(32)No-
batch_job_execution
job_execution_idBIGINTNoPK
versionBIGINTYes-
job_instance_idBIGINTNoFK → batch_job_instance.job_instance_id
create_timeTIMESTAMPNo-
start_timeTIMESTAMPYes-
end_timeTIMESTAMPYes-
statusVARCHAR(10)Yes-
exit_codeVARCHAR(2500)Yes-
exit_messageVARCHAR(2500)Yes-
last_updatedTIMESTAMPYes-
batch_job_execution_params
job_execution_idBIGINTNoFK → batch_job_execution.job_execution_id
parameter_nameVARCHAR(100)No-
parameter_typeVARCHAR(100)No-
parameter_valueVARCHAR(2500)Yes-
identifyingCHAR(1)No-
batch_step_execution
step_execution_idBIGINTNoPK
versionBIGINTNo-
step_nameVARCHAR(100)No-
job_execution_idBIGINTNoFK → batch_job_execution.job_execution_id
create_timeTIMESTAMPNo-
start_timeTIMESTAMPYes-
end_timeTIMESTAMPYes-
statusVARCHAR(10)Yes-
commit_countBIGINTYes-
read_countBIGINTYes-
filter_countBIGINTYes-
write_countBIGINTYes-
read_skip_countBIGINTYes-
write_skip_countBIGINTYes-
process_skip_countBIGINTYes-
rollback_countBIGINTYes-
exit_codeVARCHAR(2500)Yes-
exit_messageVARCHAR(2500)Yes-
last_updatedTIMESTAMPYes-
batch_step_execution_context
step_execution_idBIGINTNoPK, FK → batch_step_execution.step_execution_id
short_contextVARCHAR(2500)No-
serialized_contextTEXTYes-
batch_job_execution_context
job_execution_idBIGINTNoPK, FK → batch_job_execution.job_execution_id
short_contextVARCHAR(2500)No-
serialized_contextTEXTYes-

Table relationships

5 relationships connect the tables in this schema. Each entry shows the child columns, the parent columns they reference, and the cardinality.

One-to-many

batch_job_execution.job_instance_id → batch_job_instance.job_instance_id

One batch job instance can have many batch job executions (batch_job_execution.job_instance_id -> batch_job_instance.job_instance_id, required).

One-to-many

batch_job_execution_params.job_execution_id → batch_job_execution.job_execution_id

One batch job execution can have many batch job execution params (batch_job_execution_params.job_execution_id -> batch_job_execution.job_execution_id, required).

One-to-many

batch_step_execution.job_execution_id → batch_job_execution.job_execution_id

One batch job execution can have many batch step executions (batch_step_execution.job_execution_id -> batch_job_execution.job_execution_id, required).

One-to-one

batch_step_execution_context.step_execution_id → batch_step_execution.step_execution_id

Each batch step execution context has one batch step execution (batch_step_execution_context.step_execution_id -> batch_step_execution.step_execution_id, required).

One-to-one

batch_job_execution_context.job_execution_id → batch_job_execution.job_execution_id

Each batch job execution context has one batch job execution (batch_job_execution_context.job_execution_id -> batch_job_execution.job_execution_id, required).

Common queries

These PostgreSQL queries run against the schema shown on this page.

Recent job executions

Show the latest job runs with their instance name.

select ji.job_name, je.job_execution_id, je.status, je.create_time
from batch_job_execution je
join batch_job_instance ji on ji.job_instance_id = je.job_instance_id
order by je.create_time desc;

Failed steps

List step executions that ended in FAILED status.

select je.job_execution_id, se.step_name, se.status, se.exit_code
from batch_step_execution se
join batch_job_execution je on je.job_execution_id = se.job_execution_id
where se.status = 'FAILED'
order by se.step_execution_id;

Read and write totals

Sum step counters grouped by step name.

select step_name,
       sum(read_count) as read_count,
       sum(write_count) as write_count
from batch_step_execution
group by step_name
order by step_name;

Job parameters

Show the parameters supplied to each execution.

select jp.job_execution_id, jp.parameter_name, jp.parameter_value
from batch_job_execution_params jp
order by jp.job_execution_id, jp.parameter_name;

Frequently asked questions

Related schema diagrams

Visualize your own database

Paste your PostgreSQL connection string and get an interactive ER diagram of your own schema in under 10 seconds. No signup required.

Try it free →