我们可以自定义Spring Batch元表吗?

时间:2017-07-12 20:10:45

标签: spring spring-batch

我们可以更改这些表的名称吗?

  Default Table Name->Customize Name
 -----------------------------------------
• BATCH_JOB_INSTANCE->JobInstanceDescription
• BATCH_JOB_PARAMS-> JobExecutionParameters
• BATCH_JOB_EXECUTION[Customized Name Will Be Provided In Similar Fashion]
• BATCH_JOB_EXECUTION_CONTEXT->[Customized Name Will Be Provided In Similar Fashion]
• BATCH_STEP_EXECUTION->[Customized Name Will Be Provided In Similar Fashion]
• BATCH_STEP_EXECUTION_CONTEXT->[Customized Name Will Be Provided In Similar Fashion]

1 个答案:

答案 0 :(得分:3)

不,无法完全重命名Spring Batch元数据表。只能更改前缀部分。

我的回答是基于这样一个事实:我查看了Spring Batch API中几个类的代码,例如 - org.springframework.batch.core.repository.dao.JdbcExecutionContextDao& org.springframework.batch.core.repository.dao.JdbcJobInstanceDao

这些类正在使用像

这样的硬编码查询

private static final String CREATE_JOB_INSTANCE = "INSERT into %PREFIX%JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION)" + " values (?, ?, ?, ?)";

&安培;

private static final String FIND_JOB_EXECUTION_CONTEXT = "SELECT SHORT_CONTEXT, SERIALIZED_CONTEXT " + "FROM %PREFIX%JOB_EXECUTION_CONTEXT WHERE JOB_EXECUTION_ID = ?"; 等等。

所以后缀部分如JOB_INSTANCE& JOB_EXECUTION_CONTEXT是硬编码的,因此无法更改。