Fixed SimpleJdbcInsert to use SQL type info for all insert operations
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1259 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
e30dd02726
commit
d96fbcf73b
|
|
@ -339,7 +339,7 @@ public abstract class AbstractJdbcInsert {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("The following parameters are used for insert " + getInsertString() + " with: " + values);
|
logger.debug("The following parameters are used for insert " + getInsertString() + " with: " + values);
|
||||||
}
|
}
|
||||||
int updateCount = jdbcTemplate.update(getInsertString(), values.toArray());
|
int updateCount = jdbcTemplate.update(getInsertString(), values.toArray(), getInsertTypes());
|
||||||
return updateCount;
|
return updateCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -422,7 +422,7 @@ public abstract class AbstractJdbcInsert {
|
||||||
new PreparedStatementCreator() {
|
new PreparedStatementCreator() {
|
||||||
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
|
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
|
||||||
PreparedStatement ps = prepareStatementForGeneratedKeys(con);
|
PreparedStatement ps = prepareStatementForGeneratedKeys(con);
|
||||||
setParameterValues(ps, values, null);
|
setParameterValues(ps, values, getInsertTypes());
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -464,7 +464,7 @@ public abstract class AbstractJdbcInsert {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
try {
|
try {
|
||||||
ps = con.prepareStatement(getInsertString());
|
ps = con.prepareStatement(getInsertString());
|
||||||
setParameterValues(ps, values, null);
|
setParameterValues(ps, values, getInsertTypes());
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} finally {
|
} finally {
|
||||||
JdbcUtils.closeStatement(ps);
|
JdbcUtils.closeStatement(ps);
|
||||||
|
|
@ -564,14 +564,13 @@ public abstract class AbstractJdbcInsert {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Executing statement " + getInsertString() + " with batch of size: " + batchValues.length);
|
logger.debug("Executing statement " + getInsertString() + " with batch of size: " + batchValues.length);
|
||||||
}
|
}
|
||||||
final int[] columnTypes = getInsertTypes();
|
|
||||||
int[] updateCounts = jdbcTemplate.batchUpdate(
|
int[] updateCounts = jdbcTemplate.batchUpdate(
|
||||||
getInsertString(),
|
getInsertString(),
|
||||||
new BatchPreparedStatementSetter() {
|
new BatchPreparedStatementSetter() {
|
||||||
|
|
||||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||||
List<Object> values = batchValues[i];
|
List<Object> values = batchValues[i];
|
||||||
setParameterValues(ps, values, columnTypes);
|
setParameterValues(ps, values, getInsertTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBatchSize() {
|
public int getBatchSize() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue