Browse Source

changed NamedParameter/SimpleJdbcOperations parameter signatures to accept any Map value type (SPR-6046)

conversation
Juergen Hoeller 16 years ago
parent
commit
773bdcded5
  1. 30
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java
  2. 32
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java
  3. 6
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java
  4. 10
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java
  5. 24
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcOperations.java
  6. 24
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.java
  7. 29
      org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java

30
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java

@ -1,5 +1,5 @@ @@ -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 { @@ -85,7 +85,7 @@ public interface NamedParameterJdbcOperations {
* @return a result object returned by the action, or <code>null</code>
* @throws DataAccessException if there is any problem
*/
<T> T execute(String sql, Map<String, Object> paramMap, PreparedStatementCallback<T> action)
<T> T execute(String sql, Map<String, ?> paramMap, PreparedStatementCallback<T> action)
throws DataAccessException;
/**
@ -112,7 +112,7 @@ public interface NamedParameterJdbcOperations { @@ -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> T query(String sql, Map<String, Object> paramMap, ResultSetExtractor<T> rse)
<T> T query(String sql, Map<String, ?> paramMap, ResultSetExtractor<T> rse)
throws DataAccessException;
/**
@ -137,7 +137,7 @@ public interface NamedParameterJdbcOperations { @@ -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<String, Object> paramMap, RowCallbackHandler rch) throws DataAccessException;
void query(String sql, Map<String, ?> 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 { @@ -163,7 +163,7 @@ public interface NamedParameterJdbcOperations {
* @return the result List, containing mapped objects
* @throws org.springframework.dao.DataAccessException if the query fails
*/
<T> List<T> query(String sql, Map<String, Object> paramMap, RowMapper<T> rowMapper)
<T> List<T> query(String sql, Map<String, ?> paramMap, RowMapper<T> rowMapper)
throws DataAccessException;
/**
@ -196,7 +196,7 @@ public interface NamedParameterJdbcOperations { @@ -196,7 +196,7 @@ public interface NamedParameterJdbcOperations {
* one column in that row
* @throws org.springframework.dao.DataAccessException if the query fails
*/
<T> T queryForObject(String sql, Map<String, Object> paramMap, RowMapper<T> rowMapper)
<T> T queryForObject(String sql, Map<String, ?> paramMap, RowMapper<T> rowMapper)
throws DataAccessException;
/**
@ -233,7 +233,7 @@ public interface NamedParameterJdbcOperations { @@ -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> T queryForObject(String sql, Map<String, Object> paramMap, Class<T> requiredType)
<T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
throws DataAccessException;
/**
@ -272,7 +272,7 @@ public interface NamedParameterJdbcOperations { @@ -272,7 +272,7 @@ public interface NamedParameterJdbcOperations {
* @see org.springframework.jdbc.core.JdbcTemplate#queryForMap(String)
* @see org.springframework.jdbc.core.ColumnMapRowMapper
*/
Map<String, Object> queryForMap(String sql, Map<String, Object> paramMap) throws DataAccessException;
Map<String, Object> queryForMap(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
@ -305,7 +305,7 @@ public interface NamedParameterJdbcOperations { @@ -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<String, Object> paramMap) throws DataAccessException;
long queryForLong(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
@ -336,7 +336,7 @@ public interface NamedParameterJdbcOperations { @@ -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<String, Object> paramMap) throws DataAccessException;
int queryForInt(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
@ -370,7 +370,7 @@ public interface NamedParameterJdbcOperations { @@ -370,7 +370,7 @@ public interface NamedParameterJdbcOperations {
* @see org.springframework.jdbc.core.JdbcTemplate#queryForList(String, Class)
* @see org.springframework.jdbc.core.SingleColumnRowMapper
*/
<T> List<T> queryForList(String sql, Map<String, Object> paramMap, Class<T> elementType)
<T> List<T> queryForList(String sql, Map<String, ?> paramMap, Class<T> elementType)
throws DataAccessException;
/**
@ -402,7 +402,7 @@ public interface NamedParameterJdbcOperations { @@ -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<Map<String, Object>> queryForList(String sql, Map<String, Object> paramMap) throws DataAccessException;
List<Map<String, Object>> queryForList(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
@ -443,7 +443,7 @@ public interface NamedParameterJdbcOperations { @@ -443,7 +443,7 @@ public interface NamedParameterJdbcOperations {
* @see org.springframework.jdbc.core.SqlRowSetResultSetExtractor
* @see javax.sql.rowset.CachedRowSet
*/
SqlRowSet queryForRowSet(String sql, Map<String, Object> paramMap) throws DataAccessException;
SqlRowSet queryForRowSet(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Issue an update via a prepared statement, binding the given arguments.
@ -462,7 +462,7 @@ public interface NamedParameterJdbcOperations { @@ -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<String, Object> paramMap) throws DataAccessException;
int update(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Issue an update via a prepared statement, binding the given arguments,
@ -499,7 +499,7 @@ public interface NamedParameterJdbcOperations { @@ -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<String, Object>[] batchValues);
public int[] batchUpdate(String sql, Map<String, ?>[] batchValues);
/**
* Execute a batch using the supplied SQL statement with the batch of supplied arguments.

32
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java

@ -1,5 +1,5 @@ @@ -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 @@ -103,7 +103,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return getJdbcOperations().execute(getPreparedStatementCreator(sql, paramSource), action);
}
public <T> T execute(String sql, Map<String, Object> paramMap, PreparedStatementCallback<T> action)
public <T> T execute(String sql, Map<String, ?> paramMap, PreparedStatementCallback<T> action)
throws DataAccessException {
return execute(sql, new MapSqlParameterSource(paramMap), action);
@ -115,7 +115,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -115,7 +115,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rse);
}
public <T> T query(String sql, Map<String, Object> paramMap, ResultSetExtractor<T> rse)
public <T> T query(String sql, Map<String, ?> paramMap, ResultSetExtractor<T> rse)
throws DataAccessException {
return query(sql, new MapSqlParameterSource(paramMap), rse);
@ -127,7 +127,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -127,7 +127,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rch);
}
public void query(String sql, Map<String, Object> paramMap, RowCallbackHandler rch)
public void query(String sql, Map<String, ?> paramMap, RowCallbackHandler rch)
throws DataAccessException {
query(sql, new MapSqlParameterSource(paramMap), rch);
@ -139,7 +139,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -139,7 +139,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rowMapper);
}
public <T> List<T> query(String sql, Map<String, Object> paramMap, RowMapper<T> rowMapper)
public <T> List<T> query(String sql, Map<String, ?> paramMap, RowMapper<T> rowMapper)
throws DataAccessException {
return query(sql, new MapSqlParameterSource(paramMap), rowMapper);
@ -152,7 +152,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -152,7 +152,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return DataAccessUtils.requiredSingleResult(results);
}
public <T> T queryForObject(String sql, Map<String, Object> paramMap, RowMapper<T>rowMapper)
public <T> T queryForObject(String sql, Map<String, ?> paramMap, RowMapper<T>rowMapper)
throws DataAccessException {
return queryForObject(sql, new MapSqlParameterSource(paramMap), rowMapper);
@ -164,7 +164,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -164,7 +164,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
}
public <T> T queryForObject(String sql, Map<String, Object> paramMap, Class<T> requiredType)
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
throws DataAccessException {
return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
@ -174,7 +174,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -174,7 +174,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return queryForObject(sql, paramSource, new ColumnMapRowMapper());
}
public Map<String, Object> queryForMap(String sql, Map<String, Object> paramMap) throws DataAccessException {
public Map<String, Object> queryForMap(String sql, Map<String, ?> paramMap) throws DataAccessException {
return queryForObject(sql, paramMap, new ColumnMapRowMapper());
}
@ -183,7 +183,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -183,7 +183,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return (number != null ? number.longValue() : 0);
}
public long queryForLong(String sql, Map<String, Object> paramMap) throws DataAccessException {
public long queryForLong(String sql, Map<String, ?> paramMap) throws DataAccessException {
return queryForLong(sql, new MapSqlParameterSource(paramMap));
}
@ -192,7 +192,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -192,7 +192,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return (number != null ? number.intValue() : 0);
}
public int queryForInt(String sql, Map<String, Object> paramMap) throws DataAccessException {
public int queryForInt(String sql, Map<String, ?> paramMap) throws DataAccessException {
return queryForInt(sql, new MapSqlParameterSource(paramMap));
}
@ -202,7 +202,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -202,7 +202,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
}
public <T> List<T> queryForList(String sql, Map<String, Object> paramMap, Class<T> elementType)
public <T> List<T> queryForList(String sql, Map<String, ?> paramMap, Class<T> elementType)
throws DataAccessException {
return queryForList(sql, new MapSqlParameterSource(paramMap), elementType);
@ -214,7 +214,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -214,7 +214,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return query(sql, paramSource, new ColumnMapRowMapper());
}
public List<Map<String, Object>> queryForList(String sql, Map<String, Object> paramMap)
public List<Map<String, Object>> queryForList(String sql, Map<String, ?> paramMap)
throws DataAccessException {
return queryForList(sql, new MapSqlParameterSource(paramMap));
@ -225,7 +225,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -225,7 +225,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
getPreparedStatementCreator(sql, paramSource), new SqlRowSetResultSetExtractor());
}
public SqlRowSet queryForRowSet(String sql, Map<String, Object> paramMap) throws DataAccessException {
public SqlRowSet queryForRowSet(String sql, Map<String, ?> paramMap) throws DataAccessException {
return queryForRowSet(sql, new MapSqlParameterSource(paramMap));
}
@ -233,7 +233,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -233,7 +233,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return getJdbcOperations().update(getPreparedStatementCreator(sql, paramSource));
}
public int update(String sql, Map<String, Object> paramMap) throws DataAccessException {
public int update(String sql, Map<String, ?> paramMap) throws DataAccessException {
return update(sql, new MapSqlParameterSource(paramMap));
}
@ -261,10 +261,10 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -261,10 +261,10 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return getJdbcOperations().update(pscf.newPreparedStatementCreator(params), generatedKeyHolder);
}
public int[] batchUpdate(String sql, Map<String, Object>[] batchValues) {
public int[] batchUpdate(String sql, Map<String, ?>[] batchValues) {
SqlParameterSource[] batchArgs = new SqlParameterSource[batchValues.length];
int i = 0;
for (Map<String, Object> values : batchValues) {
for (Map<String, ?> values : batchValues) {
batchArgs[i] = new MapSqlParameterSource(values);
i++;
}

6
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java

@ -1,5 +1,5 @@ @@ -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 @@ -137,7 +137,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
}
@SuppressWarnings("unchecked")
public <T> T executeFunction(Class<T> returnType, Map<String, Object> args) {
public <T> T executeFunction(Class<T> returnType, Map<String, ?> args) {
return (T) doExecute(args).get(getScalarOutParameterName());
}
@ -152,7 +152,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp @@ -152,7 +152,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
}
@SuppressWarnings("unchecked")
public <T> T executeObject(Class<T> returnType, Map<String, Object> args) {
public <T> T executeObject(Class<T> returnType, Map<String, ?> args) {
return (T) doExecute(args).get(getScalarOutParameterName());
}

10
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 <code>SqlParameter</code> and <code>SqlInOutParameter</code>
* will be used to provide input values. This is different from the <code>StoredProcedure</code> class
@ -85,7 +85,7 @@ public interface SimpleJdbcCallOperations { @@ -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 { @@ -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> T executeFunction(Class<T> returnType, Map<String, Object> args);
<T> T executeFunction(Class<T> returnType, Map<String, ?> 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 { @@ -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> T executeObject(Class<T> returnType, Map<String, Object> args);
<T> T executeObject(Class<T> returnType, Map<String, ?> args);
/**
* Execute the stored procedure and return the single out parameter as an Object of the specified return type.

24
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcOperations.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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<String, Object> args) throws DataAccessException;
int queryForInt(String sql, Map<String, ?> args) throws DataAccessException;
/**
* Query for an <code>int</code> passing in a SQL query
@ -90,7 +90,7 @@ public interface SimpleJdbcOperations { @@ -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<String, Object> args) throws DataAccessException;
long queryForLong(String sql, Map<String, ?> args) throws DataAccessException;
/**
* Query for an <code>long</code> passing in a SQL query
@ -121,7 +121,7 @@ public interface SimpleJdbcOperations { @@ -121,7 +121,7 @@ public interface SimpleJdbcOperations {
* @see JdbcOperations#queryForObject(String, Class)
* @see JdbcOperations#queryForObject(String, Object[], Class)
*/
<T> T queryForObject(String sql, Class<T> requiredType, Map<String, Object> args)
<T> T queryForObject(String sql, Class<T> requiredType, Map<String, ?> args)
throws DataAccessException;
/**
@ -160,7 +160,7 @@ public interface SimpleJdbcOperations { @@ -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> T queryForObject(String sql, RowMapper<T> rm, Map<String, Object> args)
<T> T queryForObject(String sql, RowMapper<T> rm, Map<String, ?> args)
throws DataAccessException;
/**
@ -177,7 +177,7 @@ public interface SimpleJdbcOperations { @@ -177,7 +177,7 @@ public interface SimpleJdbcOperations {
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
@Deprecated
<T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args)
<T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Map<String, ?> args)
throws DataAccessException;
/**
@ -251,7 +251,7 @@ public interface SimpleJdbcOperations { @@ -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)
*/
<T> List<T> query(String sql, RowMapper<T> rm, Map<String, Object> args)
<T> List<T> query(String sql, RowMapper<T> rm, Map<String, ?> args)
throws DataAccessException;
/**
@ -268,7 +268,7 @@ public interface SimpleJdbcOperations { @@ -268,7 +268,7 @@ public interface SimpleJdbcOperations {
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
@Deprecated
<T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args)
<T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Map<String, ?> args)
throws DataAccessException;
/**
@ -342,7 +342,7 @@ public interface SimpleJdbcOperations { @@ -342,7 +342,7 @@ public interface SimpleJdbcOperations {
* @see JdbcOperations#queryForMap(String)
* @see JdbcOperations#queryForMap(String, Object[])
*/
Map<String, Object> queryForMap(String sql, Map<String, Object> args)
Map<String, Object> queryForMap(String sql, Map<String, ?> args)
throws DataAccessException;
/**
@ -383,7 +383,7 @@ public interface SimpleJdbcOperations { @@ -383,7 +383,7 @@ public interface SimpleJdbcOperations {
* @see JdbcOperations#queryForList(String)
* @see JdbcOperations#queryForList(String, Object[])
*/
List<Map<String, Object>> queryForList(String sql, Map<String, Object> args)
List<Map<String, Object>> queryForList(String sql, Map<String, ?> args)
throws DataAccessException;
/**
@ -422,7 +422,7 @@ public interface SimpleJdbcOperations { @@ -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<String, Object> args) throws DataAccessException;
int update(String sql, Map<String, ?> args) throws DataAccessException;
/**
* Execute the supplied SQL statement with supplied arguments.
@ -453,7 +453,7 @@ public interface SimpleJdbcOperations { @@ -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<String, Object>[] batchValues);
public int[] batchUpdate(String sql, Map<String, ?>[] batchValues);
/**
* Execute a batch using the supplied SQL statement with the batch of supplied arguments.

24
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.java

@ -1,5 +1,5 @@ @@ -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 { @@ -100,7 +100,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
}
public int queryForInt(String sql, Map<String, Object> args) throws DataAccessException {
public int queryForInt(String sql, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().queryForInt(sql, args);
}
@ -114,7 +114,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -114,7 +114,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
getJdbcOperations().queryForInt(sql, getArguments(args)));
}
public long queryForLong(String sql, Map<String, Object> args) throws DataAccessException {
public long queryForLong(String sql, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().queryForLong(sql, args);
}
@ -128,7 +128,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -128,7 +128,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
getJdbcOperations().queryForLong(sql, getArguments(args)));
}
public <T> T queryForObject(String sql, Class<T> requiredType, Map<String, Object> args) throws DataAccessException {
public <T> T queryForObject(String sql, Class<T> requiredType, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().queryForObject(sql, args, requiredType);
}
@ -143,12 +143,12 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -143,12 +143,12 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
getJdbcOperations().queryForObject(sql, getArguments(args), requiredType));
}
public <T> T queryForObject(String sql, RowMapper<T> rm, Map<String, Object> args) throws DataAccessException {
public <T> T queryForObject(String sql, RowMapper<T> rm, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().queryForObject(sql, args, rm);
}
@Deprecated
public <T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args) throws DataAccessException {
public <T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Map<String, ?> args) throws DataAccessException {
return queryForObject(sql, (RowMapper<T>) rm, args);
}
@ -174,12 +174,12 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -174,12 +174,12 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
return queryForObject(sql, (RowMapper<T>) rm, args);
}
public <T> List<T> query(String sql, RowMapper<T> rm, Map<String, Object> args) throws DataAccessException {
public <T> List<T> query(String sql, RowMapper<T> rm, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().query(sql, args, rm);
}
@Deprecated
public <T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args) throws DataAccessException {
public <T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Map<String, ?> args) throws DataAccessException {
return query(sql, (RowMapper<T>) rm, args);
}
@ -205,7 +205,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -205,7 +205,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
return query(sql, (RowMapper<T>) rm, args);
}
public Map<String, Object> queryForMap(String sql, Map<String, Object> args) throws DataAccessException {
public Map<String, Object> queryForMap(String sql, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().queryForMap(sql, args);
}
@ -220,7 +220,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -220,7 +220,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
getJdbcOperations().queryForMap(sql, getArguments(args)));
}
public List<Map<String, Object>> queryForList(String sql, Map<String, Object> args) throws DataAccessException {
public List<Map<String, Object>> queryForList(String sql, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().queryForList(sql, args);
}
@ -235,7 +235,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -235,7 +235,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
getJdbcOperations().queryForList(sql, getArguments(args)));
}
public int update(String sql, Map<String, Object> args) throws DataAccessException {
public int update(String sql, Map<String, ?> args) throws DataAccessException {
return getNamedParameterJdbcOperations().update(sql, args);
}
@ -257,7 +257,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations { @@ -257,7 +257,7 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
return BatchUpdateUtils.executeBatchUpdate(sql, batchArgs, argTypes, getJdbcOperations());
}
public int[] batchUpdate(String sql, Map<String, Object>[] batchValues) {
public int[] batchUpdate(String sql, Map<String, ?>[] batchValues) {
return getNamedParameterJdbcOperations().batchUpdate(sql, batchValues);
}

29
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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<String, Object> args = new HashMap<String, Object>(2);
args.put("id", arg1);
args.put("xy", arg2);
npjo.queryForInt(sql, args);
@ -173,26 +172,6 @@ public class SimpleJdbcTemplateTests extends TestCase { @@ -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();

Loading…
Cancel
Save