diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobRepositoryParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobRepositoryParser.java
index ff13ed4e1..468b781b4 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobRepositoryParser.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobRepositoryParser.java
@@ -51,6 +51,8 @@ public class JobRepositoryParser extends AbstractSingleBeanDefinitionParser {
String tablePrefix = element.getAttribute("table-prefix");
+ String maxVarCharLength = element.getAttribute("max-varchar-length");
+
String lobHandler = element.getAttribute("lob-handler");
RuntimeBeanReference ds = new RuntimeBeanReference(dataSource);
@@ -66,6 +68,9 @@ public class JobRepositoryParser extends AbstractSingleBeanDefinitionParser {
if (StringUtils.hasText(lobHandler)) {
builder.addPropertyReference("lobHandler", lobHandler);
}
+ if (StringUtils.hasText(maxVarCharLength)) {
+ builder.addPropertyValue("maxVarCharLength", maxVarCharLength);
+ }
builder.setRole(BeanDefinition.ROLE_SUPPORT);
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java
index a21b2d12f..5f97a8162 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java
@@ -68,7 +68,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
private DataFieldMaxValueIncrementerFactory incrementerFactory;
- private int exitMessageLength = AbstractJdbcBatchMetadataDao.DEFAULT_EXIT_MESSAGE_LENGTH;
+ private int maxVarCharLength = AbstractJdbcBatchMetadataDao.DEFAULT_EXIT_MESSAGE_LENGTH;
private LobHandler lobHandler;
@@ -86,14 +86,19 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
}
/**
- * Public setter for the exit message length in database. Do not set this if
- * you haven't modified the schema. Note this value will be used for both
- * {@link JdbcJobExecutionDao} and {@link JdbcStepExecutionDao}.
+ * 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.
*
- * @param exitMessageLength the exitMessageLength to set
+ * @param maxVarCharLength the exitMessageLength to set
*/
- public void setExitMessageLength(int exitMessageLength) {
- this.exitMessageLength = exitMessageLength;
+ public void setMaxVarCharLength(int maxVarCharLength) {
+ this.maxVarCharLength = maxVarCharLength;
}
/**
@@ -139,8 +144,8 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
databaseType = DatabaseType.fromMetaData(dataSource).name();
logger.info("No database type set, using meta data indicating: " + databaseType);
}
-
- if (lobHandler==null && databaseType.equalsIgnoreCase(DatabaseType.ORACLE.toString())) {
+
+ if (lobHandler == null && databaseType.equalsIgnoreCase(DatabaseType.ORACLE.toString())) {
lobHandler = new OracleLobHandler();
}
@@ -170,7 +175,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
+ "JOB_EXECUTION_SEQ"));
dao.setTablePrefix(tablePrefix);
dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType));
- dao.setExitMessageLength(exitMessageLength);
+ dao.setExitMessageLength(maxVarCharLength);
dao.afterPropertiesSet();
return dao;
}
@@ -183,7 +188,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
+ "STEP_EXECUTION_SEQ"));
dao.setTablePrefix(tablePrefix);
dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType));
- dao.setExitMessageLength(exitMessageLength);
+ dao.setExitMessageLength(maxVarCharLength);
dao.afterPropertiesSet();
return dao;
}
@@ -198,6 +203,8 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
dao.setLobHandler(lobHandler);
}
dao.afterPropertiesSet();
+ // Assume the same length.
+ dao.setShortContextLength(maxVarCharLength);
return dao;
}
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd
index 8f643784e..552d373d5 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd
@@ -182,6 +182,15 @@
]]>
+
+
+
+
+
-
+
\ No newline at end of file