BATCH-1968: Upgrade to hsqldb 2.2.9
This commit is contained in:
committed by
Michael Minella
parent
c8ce61d598
commit
082c81765f
@@ -119,9 +119,9 @@
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>1.8.0.7</version>
|
||||
<version>2.2.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -248,42 +248,41 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
|
||||
* @param sql with parameters (shortContext, longContext, executionId)
|
||||
*/
|
||||
private void persistSerializedContexts(final Map<Long, String> serializedContexts, String sql) {
|
||||
if (!serializedContexts.isEmpty()) {
|
||||
final Iterator<Long> executionIdIterator = serializedContexts.keySet().iterator();
|
||||
|
||||
final Iterator<Long> executionIdIterator = serializedContexts.keySet().iterator();
|
||||
getJdbcTemplate().batchUpdate(getQuery(sql), new BatchPreparedStatementSetter() {
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
Long executionId = executionIdIterator.next();
|
||||
String serializedContext = serializedContexts.get(executionId);
|
||||
String shortContext;
|
||||
String longContext;
|
||||
if (serializedContext.length() > shortContextLength) {
|
||||
// Overestimate length of ellipsis to be on the safe side with
|
||||
// 2-byte chars
|
||||
shortContext = serializedContext.substring(0, shortContextLength - 8) + " ...";
|
||||
longContext = serializedContext;
|
||||
} else {
|
||||
shortContext = serializedContext;
|
||||
longContext = null;
|
||||
}
|
||||
ps.setString(1, shortContext);
|
||||
if (longContext != null) {
|
||||
lobHandler.getLobCreator().setClobAsString(ps, 2, longContext);
|
||||
} else {
|
||||
ps.setNull(2, getClobTypeToUse());
|
||||
}
|
||||
ps.setLong(3, executionId);
|
||||
}
|
||||
|
||||
getJdbcTemplate().batchUpdate(getQuery(sql), new BatchPreparedStatementSetter() {
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
Long executionId = executionIdIterator.next();
|
||||
String serializedContext = serializedContexts.get(executionId);
|
||||
String shortContext;
|
||||
String longContext;
|
||||
if (serializedContext.length() > shortContextLength) {
|
||||
// Overestimate length of ellipsis to be on the safe side with
|
||||
// 2-byte chars
|
||||
shortContext = serializedContext.substring(0, shortContextLength - 8) + " ...";
|
||||
longContext = serializedContext;
|
||||
}
|
||||
else {
|
||||
shortContext = serializedContext;
|
||||
longContext = null;
|
||||
}
|
||||
ps.setString(1, shortContext);
|
||||
if (longContext != null) {
|
||||
lobHandler.getLobCreator().setClobAsString(ps, 2, longContext);
|
||||
}
|
||||
else {
|
||||
ps.setNull(2, getClobTypeToUse());
|
||||
}
|
||||
ps.setLong(3, executionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return serializedContexts.size();
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return serializedContexts.size();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String serializeContext(ExecutionContext ctx) {
|
||||
|
||||
@@ -133,44 +133,49 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
@Override
|
||||
public void saveStepExecutions(final Collection<StepExecution> stepExecutions) {
|
||||
Assert.notNull(stepExecutions, "Attempt to save a null collection of step executions");
|
||||
final Iterator<StepExecution> iterator = stepExecutions.iterator();
|
||||
getJdbcTemplate().batchUpdate(getQuery(SAVE_STEP_EXECUTION), new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return stepExecutions.size();
|
||||
}
|
||||
if (!stepExecutions.isEmpty()) {
|
||||
final Iterator<StepExecution> iterator = stepExecutions.iterator();
|
||||
getJdbcTemplate().batchUpdate(getQuery(SAVE_STEP_EXECUTION), new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
StepExecution stepExecution = iterator.next();
|
||||
List<Object[]> parameters = buildStepExecutionParameters(stepExecution);
|
||||
Object[] parameterValues = (Object[]) parameters.get(0);
|
||||
Integer[] parameterTypes = (Integer[]) parameters.get(1);
|
||||
for (int indx = 0; indx < parameterValues.length; indx++) {
|
||||
switch (parameterTypes[indx]) {
|
||||
case Types.INTEGER:
|
||||
ps.setInt(indx + 1, (Integer) parameterValues[indx]);
|
||||
break;
|
||||
case Types.VARCHAR:
|
||||
ps.setString(indx + 1, (String) parameterValues[indx]);
|
||||
break;
|
||||
case Types.TIMESTAMP:
|
||||
if (parameterValues[indx] !=null) {
|
||||
ps.setTimestamp(indx + 1, new Timestamp(((java.util.Date) parameterValues[indx]).getTime()));
|
||||
}
|
||||
break;
|
||||
case Types.BIGINT:
|
||||
ps.setLong(indx + 1, (Long) parameterValues[indx]);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"unsupported SQL parameter type for step execution field index " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return stepExecutions.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
StepExecution stepExecution = iterator.next();
|
||||
List<Object[]> parameters = buildStepExecutionParameters(stepExecution);
|
||||
Object[] parameterValues = (Object[]) parameters.get(0);
|
||||
Integer[] parameterTypes = (Integer[]) parameters.get(1);
|
||||
for (int indx = 0; indx < parameterValues.length; indx++) {
|
||||
switch (parameterTypes[indx]) {
|
||||
case Types.INTEGER:
|
||||
ps.setInt(indx + 1, (Integer) parameterValues[indx]);
|
||||
break;
|
||||
case Types.VARCHAR:
|
||||
ps.setString(indx + 1, (String) parameterValues[indx]);
|
||||
break;
|
||||
case Types.TIMESTAMP:
|
||||
if (parameterValues[indx] != null) {
|
||||
ps.setTimestamp(indx + 1, new Timestamp(((java.util.Date) parameterValues[indx]).getTime()));
|
||||
} else {
|
||||
ps.setNull(indx + 1, Types.TIMESTAMP);
|
||||
}
|
||||
break;
|
||||
case Types.BIGINT:
|
||||
ps.setLong(indx + 1, (Long) parameterValues[indx]);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"unsupported SQL parameter type for step execution field index " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) {
|
||||
Assert.isNull(stepExecution.getId(),
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.springframework.batch.item.database;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hsqldb.Types;
|
||||
import org.hsqldb.types.Types;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -53,7 +53,7 @@ public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemSt
|
||||
reader.setProcedureName("read_some_foos");
|
||||
reader.setParameters(
|
||||
new SqlParameter[] {
|
||||
new SqlParameter("from_id", Types.NUMERIC),
|
||||
new SqlParameter("from_id", Types.NUMERIC),
|
||||
new SqlParameter("to_id", Types.NUMERIC)
|
||||
});
|
||||
reader.setPreparedStatementSetter(
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hsqldb.Types;
|
||||
import org.hsqldb.types.Types;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -513,12 +513,12 @@
|
||||
<version>1.2.14</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>1.8.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>2.2.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
Reference in New Issue
Block a user