Re-added the methods using a ParameterizedRowMapper with a @deprecated notice to provide backwards compatibility (SPR-5837)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1417 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Thomas Risberg 2009-06-24 16:41:06 +00:00
parent 68c0ac014e
commit a0e279156c
2 changed files with 144 additions and 6 deletions

View File

@ -151,11 +151,11 @@ public interface SimpleJdbcOperations {
/**
* Query for an object of type <code>T</code> using the supplied
* {@link ParameterizedRowMapper} to the query results to the object.
* {@link RowMapper} to the query results to the object.
* Uses sql with the named parameter support provided by the
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link ParameterizedRowMapper} to use for result mapping
* @param rm the @{@link RowMapper} to use for result mapping
* @param args the map containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
@ -170,6 +170,23 @@ public interface SimpleJdbcOperations {
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link ParameterizedRowMapper} to use for result mapping
* @param args the map containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
* @deprecated as of Spring 3.0: Use the method using the newly genericized RowMapper interface
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
@Deprecated
<T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args)
throws DataAccessException;
/**
* Query for an object of type <code>T</code> using the supplied
* {@link RowMapper} to the query results to the object.
* Uses sql with the named parameter support provided by the
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link RowMapper} to use for result mapping
* @param args the <code>SqlParameterSource</code> containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
@ -177,6 +194,36 @@ public interface SimpleJdbcOperations {
<T> T queryForObject(String sql, RowMapper<T> rm, SqlParameterSource args)
throws DataAccessException;
/**
* Query for an object of type <code>T</code> using the supplied
* {@link ParameterizedRowMapper} to the query results to the object.
* Uses sql with the named parameter support provided by the
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link ParameterizedRowMapper} to use for result mapping
* @param args the <code>SqlParameterSource</code> containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
* @deprecated as of Spring 3.0: Use the method using the newly genericized RowMapper interface
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
@Deprecated
<T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, SqlParameterSource args)
throws DataAccessException;
/**
* Query for an object of type <code>T</code> using the supplied
* {@link RowMapper} to the query results to the object.
* Uses sql with the standard '?' placeholders for parameters
* @param sql the SQL query to run
* @param rm the @{@link RowMapper} to use for result mapping
* @param args the variable number of arguments for the query
* @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, Object... args)
throws DataAccessException;
/**
* Query for an object of type <code>T</code> using the supplied
* {@link ParameterizedRowMapper} to the query results to the object.
@ -186,17 +233,20 @@ public interface SimpleJdbcOperations {
* @param args the variable number of arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
* @deprecated as of Spring 3.0: Use the method using the newly genericized RowMapper interface
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
<T> T queryForObject(String sql, RowMapper<T> rm, Object... args)
@Deprecated
<T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Object... args)
throws DataAccessException;
/**
* Query for a {@link List} of <code>Objects</code> of type <code>T</code> using
* the supplied {@link ParameterizedRowMapper} to the query results to the object.
* the supplied {@link RowMapper} to the query results to the object.
* Uses sql with the named parameter support provided by the
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link ParameterizedRowMapper} to use for result mapping
* @param rm the @{@link RowMapper} to use for result mapping
* @param args the map containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
@ -211,6 +261,23 @@ public interface SimpleJdbcOperations {
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link ParameterizedRowMapper} to use for result mapping
* @param args the map containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
* @deprecated as of Spring 3.0: Use the method using the newly genericized RowMapper interface
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
@Deprecated
<T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args)
throws DataAccessException;
/**
* Query for a {@link List} of <code>Objects</code> of type <code>T</code> using
* the supplied {@link RowMapper} to the query results to the object.
* Uses sql with the named parameter support provided by the
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link RowMapper} to use for result mapping
* @param args the <code>SqlParameterSource</code> containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
@ -218,6 +285,36 @@ public interface SimpleJdbcOperations {
<T> List<T> query(String sql, RowMapper<T> rm, SqlParameterSource args)
throws DataAccessException;
/**
* Query for a {@link List} of <code>Objects</code> of type <code>T</code> using
* the supplied {@link ParameterizedRowMapper} to the query results to the object.
* Uses sql with the named parameter support provided by the
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}
* @param sql the SQL query to run
* @param rm the @{@link ParameterizedRowMapper} to use for result mapping
* @param args the <code>SqlParameterSource</code> containing the arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
* @deprecated as of Spring 3.0: Use the method using the newly genericized RowMapper interface
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
@Deprecated
<T> List<T> query(String sql, ParameterizedRowMapper<T> rm, SqlParameterSource args)
throws DataAccessException;
/**
* Query for a {@link List} of <code>Objects</code> of type <code>T</code> using
* the supplied {@link RowMapper} to the query results to the object.
* Uses sql with the standard '?' placeholders for parameters
* @param sql the SQL query to run
* @param rm the @{@link RowMapper} to use for result mapping
* @param args the variable number of arguments for the query
* @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, Object... args)
throws DataAccessException;
/**
* Query for a {@link List} of <code>Objects</code> of type <code>T</code> using
* the supplied {@link ParameterizedRowMapper} to the query results to the object.
@ -227,8 +324,11 @@ public interface SimpleJdbcOperations {
* @param args the variable number of arguments for the query
* @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
* @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
* @deprecated as of Spring 3.0: Use the method using the newly genericized RowMapper interface
* instead since the RowMapper and ParameterizedRowMapper interfaces are equivalent now.
*/
<T> List<T> query(String sql, RowMapper<T> rm, Object... args)
@Deprecated
<T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Object... args)
throws DataAccessException;
/**

View File

@ -151,12 +151,25 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
return getNamedParameterJdbcOperations().queryForObject(sql, args, rm);
}
@SuppressWarnings("unchecked")
@Deprecated
public <T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args) throws DataAccessException {
return queryForObject(sql, (RowMapper<T>) rm, args);
}
@SuppressWarnings("unchecked")
public <T> T queryForObject(String sql, RowMapper<T> rm, SqlParameterSource args)
throws DataAccessException {
return getNamedParameterJdbcOperations().queryForObject(sql, args, rm);
}
@SuppressWarnings("unchecked")
@Deprecated
public <T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, SqlParameterSource args)
throws DataAccessException {
return queryForObject(sql, (RowMapper<T>) rm, args);
}
@SuppressWarnings("unchecked")
public <T> T queryForObject(String sql, RowMapper<T> rm, Object... args) throws DataAccessException {
return (ObjectUtils.isEmpty(args) ?
@ -164,17 +177,36 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
getJdbcOperations().queryForObject(sql, getArguments(args), rm));
}
@SuppressWarnings("unchecked")
@Deprecated
public <T> T queryForObject(String sql, ParameterizedRowMapper<T> rm, Object... args) throws DataAccessException {
return queryForObject(sql, (RowMapper<T>)rm, args);
}
@SuppressWarnings("unchecked")
public <T> List<T> query(String sql, RowMapper<T> rm, Map<String, Object> args) throws DataAccessException {
return getNamedParameterJdbcOperations().query(sql, args, rm);
}
@SuppressWarnings("unchecked")
@Deprecated
public <T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Map<String, Object> args) throws DataAccessException {
return query(sql, (RowMapper<T>)rm, args);
}
@SuppressWarnings("unchecked")
public <T> List<T> query(String sql, RowMapper<T> rm, SqlParameterSource args)
throws DataAccessException {
return getNamedParameterJdbcOperations().query(sql, args, rm);
}
@SuppressWarnings("unchecked")
@Deprecated
public <T> List<T> query(String sql, ParameterizedRowMapper<T> rm, SqlParameterSource args)
throws DataAccessException {
return query(sql, (RowMapper<T>)rm, args);
}
@SuppressWarnings("unchecked")
public <T> List<T> query(String sql, RowMapper<T> rm, Object... args) throws DataAccessException {
return (ObjectUtils.isEmpty(args) ?
@ -182,6 +214,12 @@ public class SimpleJdbcTemplate implements SimpleJdbcOperations {
getJdbcOperations().query(sql, getArguments(args), rm));
}
@SuppressWarnings("unchecked")
@Deprecated
public <T> List<T> query(String sql, ParameterizedRowMapper<T> rm, Object... args) throws DataAccessException {
return query(sql, (RowMapper<T>)rm, args);
}
@SuppressWarnings("unchecked")
public Map<String, Object> queryForMap(String sql, Map<String, Object> args) throws DataAccessException {
return getNamedParameterJdbcOperations().queryForMap(sql, args);