From d96fbcf73b89cedf103841efde39d3a26ad5cd33 Mon Sep 17 00:00:00 2001 From: Thomas Risberg Date: Tue, 26 May 2009 21:25:35 +0000 Subject: [PATCH] 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 --- .../jdbc/core/simple/AbstractJdbcInsert.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java index c6d93230680..4370a94b8fe 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java @@ -339,7 +339,7 @@ public abstract class AbstractJdbcInsert { 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; } @@ -422,7 +422,7 @@ public abstract class AbstractJdbcInsert { new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement ps = prepareStatementForGeneratedKeys(con); - setParameterValues(ps, values, null); + setParameterValues(ps, values, getInsertTypes()); return ps; } }, @@ -464,7 +464,7 @@ public abstract class AbstractJdbcInsert { PreparedStatement ps = null; try { ps = con.prepareStatement(getInsertString()); - setParameterValues(ps, values, null); + setParameterValues(ps, values, getInsertTypes()); ps.executeUpdate(); } finally { JdbcUtils.closeStatement(ps); @@ -564,14 +564,13 @@ public abstract class AbstractJdbcInsert { 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 values = batchValues[i]; - setParameterValues(ps, values, columnTypes); + setParameterValues(ps, values, getInsertTypes()); } public int getBatchSize() {