提交 a6f3f101 编写于 作者: J Juergen Hoeller

Preparations for eventual removal of ParameterizedRowMapper along with SimpleJdbcTemplate

Issue: SPR-11895
上级 13c4a039
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -63,7 +63,7 @@ import org.springframework.util.StringUtils; ...@@ -63,7 +63,7 @@ import org.springframework.util.StringUtils;
* will have been set to the primitive's default value instead of null. * will have been set to the primitive's default value instead of null.
* *
* <p>Please note that this class is designed to provide convenience rather than high performance. * <p>Please note that this class is designed to provide convenience rather than high performance.
* For best performance consider using a custom RowMapper. * For best performance, consider using a custom {@link RowMapper} implementation.
* *
* @author Thomas Risberg * @author Thomas Risberg
* @author Juergen Hoeller * @author Juergen Hoeller
......
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -185,4 +185,17 @@ public class SingleColumnRowMapper<T> implements RowMapper<T> { ...@@ -185,4 +185,17 @@ public class SingleColumnRowMapper<T> implements RowMapper<T> {
} }
} }
/**
* Static factory method to create a new ParameterizedSingleColumnRowMapper
* (with the required type specified only once).
* @param requiredType the type that each result object is expected to match
* @since 4.1
*/
public static <T> SingleColumnRowMapper<T> newInstance(Class<T> requiredType) {
SingleColumnRowMapper<T> newInstance = new SingleColumnRowMapper<T>();
newInstance.setRequiredType(requiredType);
return newInstance;
}
} }
...@@ -43,13 +43,17 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper; ...@@ -43,13 +43,17 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
* try using column aliases in the SQL statement like "select fname as first_name from customer". * try using column aliases in the SQL statement like "select fname as first_name from customer".
* *
* <p>Please note that this class is designed to provide convenience rather than high performance. * <p>Please note that this class is designed to provide convenience rather than high performance.
* For best performance consider using a custom RowMapper. * For best performance, consider using a custom {@link org.springframework.jdbc.core.RowMapper}
* implementation.
* *
* @author Thomas Risberg * @author Thomas Risberg
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5 * @since 2.5
* @see ParameterizedRowMapper * @see ParameterizedRowMapper
* @deprecated along with {@link SimpleJdbcTemplate}, in favor of the regular
* {@link org.springframework.jdbc.core.BeanPropertyRowMapper}
*/ */
@Deprecated
public class ParameterizedBeanPropertyRowMapper<T> extends BeanPropertyRowMapper<T> public class ParameterizedBeanPropertyRowMapper<T> extends BeanPropertyRowMapper<T>
implements ParameterizedRowMapper<T> { implements ParameterizedRowMapper<T> {
......
...@@ -27,7 +27,10 @@ import org.springframework.jdbc.core.RowMapper; ...@@ -27,7 +27,10 @@ import org.springframework.jdbc.core.RowMapper;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.0 * @since 2.0
* @see org.springframework.jdbc.core.simple.SimpleJdbcOperations * @see org.springframework.jdbc.core.simple.SimpleJdbcOperations
* @deprecated along with {@link SimpleJdbcTemplate}, in favor of the regular
* {@link org.springframework.jdbc.core.SingleColumnRowMapper}
*/ */
@Deprecated
public interface ParameterizedRowMapper<T> extends RowMapper<T> { public interface ParameterizedRowMapper<T> extends RowMapper<T> {
} }
...@@ -32,7 +32,10 @@ import org.springframework.jdbc.core.SingleColumnRowMapper; ...@@ -32,7 +32,10 @@ import org.springframework.jdbc.core.SingleColumnRowMapper;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5.2 * @since 2.5.2
* @deprecated along with {@link SimpleJdbcTemplate}, in favor of the regular
* {@link org.springframework.jdbc.core.SingleColumnRowMapper}
*/ */
@Deprecated
public class ParameterizedSingleColumnRowMapper<T> extends SingleColumnRowMapper<T> public class ParameterizedSingleColumnRowMapper<T> extends SingleColumnRowMapper<T>
implements ParameterizedRowMapper<T> { implements ParameterizedRowMapper<T> {
...@@ -42,9 +45,9 @@ public class ParameterizedSingleColumnRowMapper<T> extends SingleColumnRowMapper ...@@ -42,9 +45,9 @@ public class ParameterizedSingleColumnRowMapper<T> extends SingleColumnRowMapper
* @param requiredType the type that each result object is expected to match * @param requiredType the type that each result object is expected to match
*/ */
public static <T> ParameterizedSingleColumnRowMapper<T> newInstance(Class<T> requiredType) { public static <T> ParameterizedSingleColumnRowMapper<T> newInstance(Class<T> requiredType) {
ParameterizedSingleColumnRowMapper<T> rm = new ParameterizedSingleColumnRowMapper<T>(); ParameterizedSingleColumnRowMapper<T> newInstance = new ParameterizedSingleColumnRowMapper<T>();
rm.setRequiredType(requiredType); newInstance.setRequiredType(requiredType);
return rm; return newInstance;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册