From 773bdcded5df628d2127991fb155e2850301d4cd Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 27 Aug 2009 13:53:00 +0000 Subject: [PATCH] changed NamedParameter/SimpleJdbcOperations parameter signatures to accept any Map value type (SPR-6046) --- .../NamedParameterJdbcOperations.java | 30 ++++++++--------- .../NamedParameterJdbcTemplate.java | 32 +++++++++---------- .../jdbc/core/simple/SimpleJdbcCall.java | 6 ++-- .../core/simple/SimpleJdbcCallOperations.java | 10 +++--- .../core/simple/SimpleJdbcOperations.java | 24 +++++++------- .../jdbc/core/simple/SimpleJdbcTemplate.java | 24 +++++++------- .../core/simple/SimpleJdbcTemplateTests.java | 29 +++-------------- 7 files changed, 67 insertions(+), 88 deletions(-) diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java index 81455973a1c..15a7a9e4ba5 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public interface NamedParameterJdbcOperations { * @return a result object returned by the action, or null * @throws DataAccessException if there is any problem */ - T execute(String sql, Map paramMap, PreparedStatementCallback action) + T execute(String sql, Map paramMap, PreparedStatementCallback action) throws DataAccessException; /** @@ -112,7 +112,7 @@ public interface NamedParameterJdbcOperations { * @return an arbitrary result object, as returned by the ResultSetExtractor * @throws org.springframework.dao.DataAccessException if the query fails */ - T query(String sql, Map paramMap, ResultSetExtractor rse) + T query(String sql, Map paramMap, ResultSetExtractor rse) throws DataAccessException; /** @@ -137,7 +137,7 @@ public interface NamedParameterJdbcOperations { * @param rch object that will extract results, one row at a time * @throws org.springframework.dao.DataAccessException if the query fails */ - void query(String sql, Map paramMap, RowCallbackHandler rch) throws DataAccessException; + void query(String sql, Map paramMap, RowCallbackHandler rch) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a list @@ -163,7 +163,7 @@ public interface NamedParameterJdbcOperations { * @return the result List, containing mapped objects * @throws org.springframework.dao.DataAccessException if the query fails */ - List query(String sql, Map paramMap, RowMapper rowMapper) + List query(String sql, Map paramMap, RowMapper rowMapper) throws DataAccessException; /** @@ -196,7 +196,7 @@ public interface NamedParameterJdbcOperations { * one column in that row * @throws org.springframework.dao.DataAccessException if the query fails */ - T queryForObject(String sql, Map paramMap, RowMapper rowMapper) + T queryForObject(String sql, Map paramMap, RowMapper rowMapper) throws DataAccessException; /** @@ -233,7 +233,7 @@ public interface NamedParameterJdbcOperations { * @throws org.springframework.dao.DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForObject(String, Class) */ - T queryForObject(String sql, Map paramMap, Class requiredType) + T queryForObject(String sql, Map paramMap, Class requiredType) throws DataAccessException; /** @@ -272,7 +272,7 @@ public interface NamedParameterJdbcOperations { * @see org.springframework.jdbc.core.JdbcTemplate#queryForMap(String) * @see org.springframework.jdbc.core.ColumnMapRowMapper */ - Map queryForMap(String sql, Map paramMap) throws DataAccessException; + Map queryForMap(String sql, Map paramMap) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -305,7 +305,7 @@ public interface NamedParameterJdbcOperations { * @throws org.springframework.dao.DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForLong(String) */ - long queryForLong(String sql, Map paramMap) throws DataAccessException; + long queryForLong(String sql, Map paramMap) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -336,7 +336,7 @@ public interface NamedParameterJdbcOperations { * @throws org.springframework.dao.DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForInt(String) */ - int queryForInt(String sql, Map paramMap) throws DataAccessException; + int queryForInt(String sql, Map paramMap) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -370,7 +370,7 @@ public interface NamedParameterJdbcOperations { * @see org.springframework.jdbc.core.JdbcTemplate#queryForList(String, Class) * @see org.springframework.jdbc.core.SingleColumnRowMapper */ - List queryForList(String sql, Map paramMap, Class elementType) + List queryForList(String sql, Map paramMap, Class elementType) throws DataAccessException; /** @@ -402,7 +402,7 @@ public interface NamedParameterJdbcOperations { * @throws org.springframework.dao.DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForList(String) */ - List> queryForList(String sql, Map paramMap) throws DataAccessException; + List> queryForList(String sql, Map paramMap) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -443,7 +443,7 @@ public interface NamedParameterJdbcOperations { * @see org.springframework.jdbc.core.SqlRowSetResultSetExtractor * @see javax.sql.rowset.CachedRowSet */ - SqlRowSet queryForRowSet(String sql, Map paramMap) throws DataAccessException; + SqlRowSet queryForRowSet(String sql, Map paramMap) throws DataAccessException; /** * Issue an update via a prepared statement, binding the given arguments. @@ -462,7 +462,7 @@ public interface NamedParameterJdbcOperations { * @return the number of rows affected * @throws org.springframework.dao.DataAccessException if there is any problem issuing the update */ - int update(String sql, Map paramMap) throws DataAccessException; + int update(String sql, Map paramMap) throws DataAccessException; /** * Issue an update via a prepared statement, binding the given arguments, @@ -499,7 +499,7 @@ public interface NamedParameterJdbcOperations { * @param batchValues the array of Maps containing the batch of arguments for the query * @return an array containing the numbers of rows affected by each update in the batch */ - public int[] batchUpdate(String sql, Map[] batchValues); + public int[] batchUpdate(String sql, Map[] batchValues); /** * Execute a batch using the supplied SQL statement with the batch of supplied arguments. diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java index baf55b2f65a..feca9e1e53e 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,7 +103,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return getJdbcOperations().execute(getPreparedStatementCreator(sql, paramSource), action); } - public T execute(String sql, Map paramMap, PreparedStatementCallback action) + public T execute(String sql, Map paramMap, PreparedStatementCallback action) throws DataAccessException { return execute(sql, new MapSqlParameterSource(paramMap), action); @@ -115,7 +115,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rse); } - public T query(String sql, Map paramMap, ResultSetExtractor rse) + public T query(String sql, Map paramMap, ResultSetExtractor rse) throws DataAccessException { return query(sql, new MapSqlParameterSource(paramMap), rse); @@ -127,7 +127,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rch); } - public void query(String sql, Map paramMap, RowCallbackHandler rch) + public void query(String sql, Map paramMap, RowCallbackHandler rch) throws DataAccessException { query(sql, new MapSqlParameterSource(paramMap), rch); @@ -139,7 +139,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rowMapper); } - public List query(String sql, Map paramMap, RowMapper rowMapper) + public List query(String sql, Map paramMap, RowMapper rowMapper) throws DataAccessException { return query(sql, new MapSqlParameterSource(paramMap), rowMapper); @@ -152,7 +152,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return DataAccessUtils.requiredSingleResult(results); } - public T queryForObject(String sql, Map paramMap, RowMapperrowMapper) + public T queryForObject(String sql, Map paramMap, RowMapperrowMapper) throws DataAccessException { return queryForObject(sql, new MapSqlParameterSource(paramMap), rowMapper); @@ -164,7 +164,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return queryForObject(sql, paramSource, new SingleColumnRowMapper(requiredType)); } - public T queryForObject(String sql, Map paramMap, Class requiredType) + public T queryForObject(String sql, Map paramMap, Class requiredType) throws DataAccessException { return queryForObject(sql, paramMap, new SingleColumnRowMapper(requiredType)); @@ -174,7 +174,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return queryForObject(sql, paramSource, new ColumnMapRowMapper()); } - public Map queryForMap(String sql, Map paramMap) throws DataAccessException { + public Map queryForMap(String sql, Map paramMap) throws DataAccessException { return queryForObject(sql, paramMap, new ColumnMapRowMapper()); } @@ -183,7 +183,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return (number != null ? number.longValue() : 0); } - public long queryForLong(String sql, Map paramMap) throws DataAccessException { + public long queryForLong(String sql, Map paramMap) throws DataAccessException { return queryForLong(sql, new MapSqlParameterSource(paramMap)); } @@ -192,7 +192,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return (number != null ? number.intValue() : 0); } - public int queryForInt(String sql, Map paramMap) throws DataAccessException { + public int queryForInt(String sql, Map paramMap) throws DataAccessException { return queryForInt(sql, new MapSqlParameterSource(paramMap)); } @@ -202,7 +202,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return query(sql, paramSource, new SingleColumnRowMapper(elementType)); } - public List queryForList(String sql, Map paramMap, Class elementType) + public List queryForList(String sql, Map paramMap, Class elementType) throws DataAccessException { return queryForList(sql, new MapSqlParameterSource(paramMap), elementType); @@ -214,7 +214,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return query(sql, paramSource, new ColumnMapRowMapper()); } - public List> queryForList(String sql, Map paramMap) + public List> queryForList(String sql, Map paramMap) throws DataAccessException { return queryForList(sql, new MapSqlParameterSource(paramMap)); @@ -225,7 +225,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations getPreparedStatementCreator(sql, paramSource), new SqlRowSetResultSetExtractor()); } - public SqlRowSet queryForRowSet(String sql, Map paramMap) throws DataAccessException { + public SqlRowSet queryForRowSet(String sql, Map paramMap) throws DataAccessException { return queryForRowSet(sql, new MapSqlParameterSource(paramMap)); } @@ -233,7 +233,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return getJdbcOperations().update(getPreparedStatementCreator(sql, paramSource)); } - public int update(String sql, Map paramMap) throws DataAccessException { + public int update(String sql, Map paramMap) throws DataAccessException { return update(sql, new MapSqlParameterSource(paramMap)); } @@ -261,10 +261,10 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations return getJdbcOperations().update(pscf.newPreparedStatementCreator(params), generatedKeyHolder); } - public int[] batchUpdate(String sql, Map[] batchValues) { + public int[] batchUpdate(String sql, Map[] batchValues) { SqlParameterSource[] batchArgs = new SqlParameterSource[batchValues.length]; int i = 0; - for (Map values : batchValues) { + for (Map values : batchValues) { batchArgs[i] = new MapSqlParameterSource(values); i++; } diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java index 693c7d00da6..b6073895c3c 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,7 +137,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp } @SuppressWarnings("unchecked") - public T executeFunction(Class returnType, Map args) { + public T executeFunction(Class returnType, Map args) { return (T) doExecute(args).get(getScalarOutParameterName()); } @@ -152,7 +152,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp } @SuppressWarnings("unchecked") - public T executeObject(Class returnType, Map args) { + public T executeObject(Class returnType, Map args) { return (T) doExecute(args).get(getScalarOutParameterName()); } diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java index 2bc96445c4d..bf9c6b4ff3c 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public interface SimpleJdbcCallOperations { SimpleJdbcCallOperations withReturnValue(); /** - * Specify one or more parameters if desired. These parameters will be supplemented with any + * Specify one or more parameters if desired. These parameters will be supplemented with any * parameter information retrieved from the database meta data. * Note that only parameters declared as SqlParameter and SqlInOutParameter * will be used to provide input values. This is different from the StoredProcedure class @@ -85,7 +85,7 @@ public interface SimpleJdbcCallOperations { /** * Used to specify when a ResultSet is returned by the stored procedure and you want it mapped - * by a RowMapper. The results will be returned using the parameter name specified. Multiple + * by a RowMapper. The results will be returned using the parameter name specified. Multiple * ResultSets must be declared in the correct order. If the database you are using uses ref cursors * then the name specified must match the name of the parameter declared for the procedure in the * database. @@ -114,7 +114,7 @@ public interface SimpleJdbcCallOperations { * @param returnType the type of the value to return * @param args Map containing the parameter values to be used in the call. */ - T executeFunction(Class returnType, Map args); + T executeFunction(Class returnType, Map args); /** * Execute the stored function and return the results obtained as an Object of the specified return type. @@ -140,7 +140,7 @@ public interface SimpleJdbcCallOperations { * @param returnType the type of the value to return * @param args Map containing the parameter values to be used in the call. */ - T executeObject(Class returnType, Map args); + T executeObject(Class returnType, Map args); /** * Execute the stored procedure and return the single out parameter as an Object of the specified return type. diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcOperations.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcOperations.java index a7355a3257d..c6a0263fe85 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcOperations.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public interface SimpleJdbcOperations { * @param sql the SQL query to run. * @param args the map containing the arguments for the query */ - int queryForInt(String sql, Map args) throws DataAccessException; + int queryForInt(String sql, Map args) throws DataAccessException; /** * Query for an int passing in a SQL query @@ -90,7 +90,7 @@ public interface SimpleJdbcOperations { * @param sql the SQL query to run. * @param args the map containing the arguments for the query */ - long queryForLong(String sql, Map args) throws DataAccessException; + long queryForLong(String sql, Map args) throws DataAccessException; /** * Query for an long passing in a SQL query @@ -121,7 +121,7 @@ public interface SimpleJdbcOperations { * @see JdbcOperations#queryForObject(String, Class) * @see JdbcOperations#queryForObject(String, Object[], Class) */ - T queryForObject(String sql, Class requiredType, Map args) + T queryForObject(String sql, Class requiredType, Map args) throws DataAccessException; /** @@ -160,7 +160,7 @@ public interface SimpleJdbcOperations { * @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper) * @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper) */ - T queryForObject(String sql, RowMapper rm, Map args) + T queryForObject(String sql, RowMapper rm, Map args) throws DataAccessException; /** @@ -177,7 +177,7 @@ public interface SimpleJdbcOperations { * instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now. */ @Deprecated - T queryForObject(String sql, ParameterizedRowMapper rm, Map args) + T queryForObject(String sql, ParameterizedRowMapper rm, Map args) throws DataAccessException; /** @@ -251,7 +251,7 @@ public interface SimpleJdbcOperations { * @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper) * @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper) */ - List query(String sql, RowMapper rm, Map args) + List query(String sql, RowMapper rm, Map args) throws DataAccessException; /** @@ -268,7 +268,7 @@ public interface SimpleJdbcOperations { * instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now. */ @Deprecated - List query(String sql, ParameterizedRowMapper rm, Map args) + List query(String sql, ParameterizedRowMapper rm, Map args) throws DataAccessException; /** @@ -342,7 +342,7 @@ public interface SimpleJdbcOperations { * @see JdbcOperations#queryForMap(String) * @see JdbcOperations#queryForMap(String, Object[]) */ - Map queryForMap(String sql, Map args) + Map queryForMap(String sql, Map args) throws DataAccessException; /** @@ -383,7 +383,7 @@ public interface SimpleJdbcOperations { * @see JdbcOperations#queryForList(String) * @see JdbcOperations#queryForList(String, Object[]) */ - List> queryForList(String sql, Map args) + List> queryForList(String sql, Map args) throws DataAccessException; /** @@ -422,7 +422,7 @@ public interface SimpleJdbcOperations { * @return the numbers of rows affected by the update * @see NamedParameterJdbcOperations#update(String, Map) */ - int update(String sql, Map args) throws DataAccessException; + int update(String sql, Map args) throws DataAccessException; /** * Execute the supplied SQL statement with supplied arguments. @@ -453,7 +453,7 @@ public interface SimpleJdbcOperations { * @param batchValues the array of Maps containing the batch of arguments for the query * @return an array containing the numbers of rows affected by each update in the batch */ - public int[] batchUpdate(String sql, Map[] batchValues); + public int[] batchUpdate(String sql, Map[] batchValues); /** * Execute a batch using the supplied SQL statement with the batch of supplied arguments. diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.java index 097ffbf9530..557137bd673 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,7 +100,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { } - public int queryForInt(String sql, Map args) throws DataAccessException { + public int queryForInt(String sql, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().queryForInt(sql, args); } @@ -114,7 +114,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { getJdbcOperations().queryForInt(sql, getArguments(args))); } - public long queryForLong(String sql, Map args) throws DataAccessException { + public long queryForLong(String sql, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().queryForLong(sql, args); } @@ -128,7 +128,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { getJdbcOperations().queryForLong(sql, getArguments(args))); } - public T queryForObject(String sql, Class requiredType, Map args) throws DataAccessException { + public T queryForObject(String sql, Class requiredType, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().queryForObject(sql, args, requiredType); } @@ -143,12 +143,12 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { getJdbcOperations().queryForObject(sql, getArguments(args), requiredType)); } - public T queryForObject(String sql, RowMapper rm, Map args) throws DataAccessException { + public T queryForObject(String sql, RowMapper rm, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().queryForObject(sql, args, rm); } @Deprecated - public T queryForObject(String sql, ParameterizedRowMapper rm, Map args) throws DataAccessException { + public T queryForObject(String sql, ParameterizedRowMapper rm, Map args) throws DataAccessException { return queryForObject(sql, (RowMapper) rm, args); } @@ -174,12 +174,12 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { return queryForObject(sql, (RowMapper) rm, args); } - public List query(String sql, RowMapper rm, Map args) throws DataAccessException { + public List query(String sql, RowMapper rm, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().query(sql, args, rm); } @Deprecated - public List query(String sql, ParameterizedRowMapper rm, Map args) throws DataAccessException { + public List query(String sql, ParameterizedRowMapper rm, Map args) throws DataAccessException { return query(sql, (RowMapper) rm, args); } @@ -205,7 +205,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { return query(sql, (RowMapper) rm, args); } - public Map queryForMap(String sql, Map args) throws DataAccessException { + public Map queryForMap(String sql, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().queryForMap(sql, args); } @@ -220,7 +220,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { getJdbcOperations().queryForMap(sql, getArguments(args))); } - public List> queryForList(String sql, Map args) throws DataAccessException { + public List> queryForList(String sql, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().queryForList(sql, args); } @@ -235,7 +235,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { getJdbcOperations().queryForList(sql, getArguments(args))); } - public int update(String sql, Map args) throws DataAccessException { + public int update(String sql, Map args) throws DataAccessException { return getNamedParameterJdbcOperations().update(sql, args); } @@ -257,7 +257,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { return BatchUpdateUtils.executeBatchUpdate(sql, batchArgs, argTypes, getJdbcOperations()); } - public int[] batchUpdate(String sql, Map[] batchValues) { + public int[] batchUpdate(String sql, Map[] batchValues) { return getNamedParameterJdbcOperations().batchUpdate(sql, batchValues); } diff --git a/org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java b/org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java index 6e072e2ea1f..a80ebbe4d46 100644 --- a/org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java +++ b/org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,17 +29,16 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; - import javax.sql.DataSource; import junit.framework.TestCase; +import org.apache.commons.logging.LogFactory; import org.easymock.MockControl; import org.easymock.internal.ArrayMatcher; -import org.apache.commons.logging.LogFactory; +import org.springframework.jdbc.core.BatchUpdateTestHelper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.BatchUpdateTestHelper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.jdbc.core.namedparam.SqlParameterSource; @@ -102,7 +101,7 @@ public class SimpleJdbcTemplateTests extends TestCase { MockControl mc = MockControl.createControl(NamedParameterJdbcOperations.class); NamedParameterJdbcOperations npjo = (NamedParameterJdbcOperations) mc.getMock(); - Map args = new HashMap(2); + Map args = new HashMap(2); args.put("id", arg1); args.put("xy", arg2); npjo.queryForInt(sql, args); @@ -173,26 +172,6 @@ public class SimpleJdbcTemplateTests extends TestCase { mc.verify(); } - public void testQueryForLongWithMap() { - String sql = "SELECT COUNT(0) FROM BAR WHERE ID=? AND XY=?"; - long expectedResult = 666; - double arg1 = 24.7; - String arg2 = "foo"; - Object arg3 = new Object(); - - MockControl mc = MockControl.createControl(JdbcOperations.class); - JdbcOperations jo = (JdbcOperations) mc.getMock(); - jo.queryForLong(sql, new Object[]{arg1, arg2, arg3}); - mc.setDefaultMatcher(new ArrayMatcher()); - mc.setReturnValue(expectedResult); - mc.replay(); - - SimpleJdbcTemplate jth = new SimpleJdbcTemplate(jo); - long result = jth.queryForLong(sql, arg1, arg2, arg3); - assertEquals(expectedResult, result); - mc.verify(); - } - public void testQueryForObjectWithoutArgs() throws Exception { String sql = "SELECT SYSDATE FROM DUAL"; Date expectedResult = new Date();