BATCH-1232: changed Sybase to use SQL type LONGVARCHAR instead of CLOB when setting context CLOB/TEXT column to null
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcOperations;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -37,6 +39,8 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
|
||||
public static final int DEFAULT_EXIT_MESSAGE_LENGTH = 2500;
|
||||
|
||||
private String tablePrefix = DEFAULT_TABLE_PREFIX;
|
||||
|
||||
private int clobTypeToUse = Types.CLOB;
|
||||
|
||||
private SimpleJdbcOperations jdbcTemplate;
|
||||
|
||||
@@ -66,6 +70,14 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
|
||||
protected SimpleJdbcOperations getJdbcTemplate() {
|
||||
return jdbcTemplate;
|
||||
}
|
||||
|
||||
public int getClobTypeToUse() {
|
||||
return clobTypeToUse;
|
||||
}
|
||||
|
||||
public void setClobTypeToUse(int clobTypeToUse) {
|
||||
this.clobTypeToUse = clobTypeToUse;
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(jdbcTemplate);
|
||||
|
||||
@@ -180,7 +180,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
|
||||
lobHandler.getLobCreator().setClobAsString(ps, 2, longContext);
|
||||
}
|
||||
else {
|
||||
ps.setNull(2, Types.CLOB);
|
||||
ps.setNull(2, getClobTypeToUse());
|
||||
}
|
||||
ps.setLong(3, executionId);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.batch.core.repository.support;
|
||||
|
||||
import static org.springframework.batch.support.DatabaseType.SYBASE;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -144,6 +148,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
|
||||
dao.setJobExecutionIncrementer(incrementerFactory.getIncrementer(databaseType, tablePrefix
|
||||
+ "JOB_EXECUTION_SEQ"));
|
||||
dao.setTablePrefix(tablePrefix);
|
||||
dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType));
|
||||
dao.setExitMessageLength(exitMessageLength);
|
||||
dao.afterPropertiesSet();
|
||||
return dao;
|
||||
@@ -156,6 +161,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
|
||||
dao.setStepExecutionIncrementer(incrementerFactory.getIncrementer(databaseType, tablePrefix
|
||||
+ "STEP_EXECUTION_SEQ"));
|
||||
dao.setTablePrefix(tablePrefix);
|
||||
dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType));
|
||||
dao.setExitMessageLength(exitMessageLength);
|
||||
dao.afterPropertiesSet();
|
||||
return dao;
|
||||
@@ -166,8 +172,18 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
|
||||
JdbcExecutionContextDao dao = new JdbcExecutionContextDao();
|
||||
dao.setJdbcTemplate(jdbcTemplate);
|
||||
dao.setTablePrefix(tablePrefix);
|
||||
dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType));
|
||||
dao.afterPropertiesSet();
|
||||
return dao;
|
||||
}
|
||||
|
||||
private int determineClobTypeToUse(String databaseType) {
|
||||
if (SYBASE == DatabaseType.valueOf(databaseType.toUpperCase())) {
|
||||
return Types.LONGVARCHAR;
|
||||
}
|
||||
else {
|
||||
return Types.CLOB;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user