Skip to content

Commit

Permalink
Use separate parameters for short_context length and exit_message len…
Browse files Browse the repository at this point in the history
…gth in JobRepositoryFactoryBean

Resolves #1617
  • Loading branch information
fmbenhassine committed Sep 18, 2023
1 parent 0a96669 commit f64d6e8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
Expand Down Expand Up @@ -28,6 +28,7 @@
* jdbcTemplate for subclasses and handles table prefixes.
*
* @author Robert Kasanicky
* @author Mahmoud Ben Hassine
*/
public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {

Expand All @@ -38,6 +39,8 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {

public static final int DEFAULT_EXIT_MESSAGE_LENGTH = 2500;

public static final int DEFAULT_SHORT_CONTEXT_LENGTH = 2500;

private String tablePrefix = DEFAULT_TABLE_PREFIX;

private int clobTypeToUse = Types.CLOB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i

private JobKeyGenerator jobKeyGenerator;

private int maxVarCharLength = AbstractJdbcBatchMetadataDao.DEFAULT_EXIT_MESSAGE_LENGTH;
private int maxVarCharLengthForExitMessage = AbstractJdbcBatchMetadataDao.DEFAULT_EXIT_MESSAGE_LENGTH;

private int maxVarCharLengthForShortContext = AbstractJdbcBatchMetadataDao.DEFAULT_SHORT_CONTEXT_LENGTH;

private LobHandler lobHandler;

Expand Down Expand Up @@ -138,14 +140,44 @@ public void setLobHandler(LobHandler lobHandler) {
* Public setter for the length of long string columns in database. Do not set this if
* you haven't modified the schema. Note this value will be used for the exit message
* in both {@link JdbcJobExecutionDao} and {@link JdbcStepExecutionDao} and also the
* short version of the execution context in {@link JdbcExecutionContextDao} . For
* databases with multi-byte character sets this number can be smaller (by up to a
* factor of 2 for 2-byte characters) than the declaration of the column length in the
* DDL for the tables.
* short version of the execution context in {@link JdbcExecutionContextDao} . If you
* want to use separate values for exit message and short context, then use
* {@link #setMaxVarCharLengthForExitMessage(int)} and
* {@link #setMaxVarCharLengthForShortContext(int)}. For databases with multi-byte
* character sets this number can be smaller (by up to a factor of 2 for 2-byte
* characters) than the declaration of the column length in the DDL for the tables.
* @param maxVarCharLength the exitMessageLength to set
*/
public void setMaxVarCharLength(int maxVarCharLength) {
this.maxVarCharLength = maxVarCharLength;
this.maxVarCharLengthForExitMessage = maxVarCharLength;
this.maxVarCharLengthForShortContext = maxVarCharLength;
}

/**
* Public setter for the length of short context string column in database. Do not set
* this if you haven't modified the schema. For databases with multi-byte character
* sets this number can be smaller (by up to a factor of 2 for 2-byte characters) than
* the declaration of the column length in the DDL for the tables. Defaults to
* {@link AbstractJdbcBatchMetadataDao#DEFAULT_SHORT_CONTEXT_LENGTH}
* @param maxVarCharLengthForShortContext the short context length to set
* @since 5.1
*/
public void setMaxVarCharLengthForShortContext(int maxVarCharLengthForShortContext) {
this.maxVarCharLengthForShortContext = maxVarCharLengthForShortContext;
}

/**
* Public setter for the length of the exit message in both
* {@link JdbcJobExecutionDao} and {@link JdbcStepExecutionDao}. Do not set this if
* you haven't modified the schema. For databases with multi-byte character sets this
* number can be smaller (by up to a factor of 2 for 2-byte characters) than the
* declaration of the column length in the DDL for the tables. Defaults to
* {@link AbstractJdbcBatchMetadataDao#DEFAULT_EXIT_MESSAGE_LENGTH}.
* @param maxVarCharLengthForExitMessage the exitMessageLength to set
* @since 5.1
*/
public void setMaxVarCharLengthForExitMessage(int maxVarCharLengthForExitMessage) {
this.maxVarCharLengthForExitMessage = maxVarCharLengthForExitMessage;
}

/**
Expand Down Expand Up @@ -294,7 +326,7 @@ protected JobExecutionDao createJobExecutionDao() throws Exception {
incrementerFactory.getIncrementer(databaseType, tablePrefix + "JOB_EXECUTION_SEQ"));
dao.setTablePrefix(tablePrefix);
dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType));
dao.setExitMessageLength(maxVarCharLength);
dao.setExitMessageLength(this.maxVarCharLengthForExitMessage);
dao.setConversionService(this.conversionService);
dao.afterPropertiesSet();
return dao;
Expand All @@ -308,7 +340,7 @@ protected StepExecutionDao createStepExecutionDao() throws Exception {
incrementerFactory.getIncrementer(databaseType, tablePrefix + "STEP_EXECUTION_SEQ"));
dao.setTablePrefix(tablePrefix);
dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType));
dao.setExitMessageLength(maxVarCharLength);
dao.setExitMessageLength(this.maxVarCharLengthForExitMessage);
dao.afterPropertiesSet();
return dao;
}
Expand All @@ -327,8 +359,7 @@ protected ExecutionContextDao createExecutionContextDao() throws Exception {
}

dao.afterPropertiesSet();
// Assume the same length.
dao.setShortContextLength(maxVarCharLength);
dao.setShortContextLength(this.maxVarCharLengthForShortContext);
return dao;
}

Expand Down

0 comments on commit f64d6e8

Please sign in to comment.