RESOLVED - issue BATCH-1416: Namespace support for max varchar length in execution context and execution daos
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,15 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="max-varchar-length" type="xsd:int">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The maximum length for a Java String that will fit in the long VARCHAR
|
||||
columns in the database. Can be less than the declared length in the DDL
|
||||
if the database supports multi-byte characters.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="table-prefix" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
</beans:bean>
|
||||
<beans:bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"/>
|
||||
|
||||
<job-repository id="jobRepo1" data-source="dataSource" transaction-manager="transactionManager" lob-handler="lobHandler"/>
|
||||
<job-repository id="jobRepo1" data-source="dataSource" transaction-manager="transactionManager" lob-handler="lobHandler" max-varchar-length="100"/>
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user