Skip to content

Commit

Permalink
fixed SimpleJdbcInsert/AbstractJdbcInsert to use SQL type info for al…
Browse files Browse the repository at this point in the history
…l insert operations (SPR-5635 backport)

git-svn-id: https://src.springframework.org/svn/spring-maintenance/trunk@17131 fd5a2b45-1f63-4059-99e9-3c7cb7fd75c8
  • Loading branch information
Thomas Risberg committed Oct 15, 2009
1 parent 2b65a53 commit 537cba0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Package org.springframework.jdbc
* added -1218 to the transientDataAccessResourceCodes for DB2 (SPR-5296 backport)
* added override for supportsGetGeneratedKeys for Derby; driver reports this is unsupported, but it seems to work OK (SPR-5306 backport)
* fixed problem retrieving out parameter for function call with MS SQL Server (SPR-5435 backport)
* fixed SimpleJdbcInsert/AbstractJdbcInsert to use SQL type info for all insert operations (SPR-5635 backport)

Package org.springframework.jms
* fixed JmsUtils.buildExceptionMessage to avoid potential NPE (SPR-5275)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private int executeInsertInternal(List<Object> values) {
if (logger.isDebugEnabled()) {
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;
}

Expand Down Expand Up @@ -422,7 +422,7 @@ private KeyHolder executeInsertAndReturnKeyHolderInternal(final List<Object> val
new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement ps = prepareStatementForGeneratedKeys(con);
setParameterValues(ps, values, null);
setParameterValues(ps, values, getInsertTypes());
return ps;
}
},
Expand Down Expand Up @@ -464,7 +464,7 @@ public Object doInConnection(Connection con) throws SQLException, DataAccessExce
PreparedStatement ps = null;
try {
ps = con.prepareStatement(getInsertString());
setParameterValues(ps, values, null);
setParameterValues(ps, values, getInsertTypes());
ps.executeUpdate();
} finally {
JdbcUtils.closeStatement(ps);
Expand Down Expand Up @@ -564,14 +564,13 @@ private int[] executeBatchInternal(final List<Object>[] batchValues) {
if (logger.isDebugEnabled()) {
logger.debug("Executing statement " + getInsertString() + " with batch of size: " + batchValues.length);
}
final int[] columnTypes = getInsertTypes();
int[] updateCounts = jdbcTemplate.batchUpdate(
getInsertString(),
new BatchPreparedStatementSetter() {

public void setValues(PreparedStatement ps, int i) throws SQLException {
List<Object> values = batchValues[i];
setParameterValues(ps, values, columnTypes);
setParameterValues(ps, values, getInsertTypes());
}

public int getBatchSize() {
Expand Down

0 comments on commit 537cba0

Please sign in to comment.