Remove deprecated rowsExpected property of SqlQuery
Closes gh-34530 Co-authored-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
parent
e9345f16dc
commit
5ffd88cd89
|
@ -64,9 +64,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
|
||||||
* @see #setSql
|
* @see #setSql
|
||||||
* @see #compile
|
* @see #compile
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public SqlFunction() {
|
public SqlFunction() {
|
||||||
setRowsExpected(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,9 +73,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
|
||||||
* @param ds the DataSource to obtain connections from
|
* @param ds the DataSource to obtain connections from
|
||||||
* @param sql the SQL to execute
|
* @param sql the SQL to execute
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public SqlFunction(DataSource ds, String sql) {
|
public SqlFunction(DataSource ds, String sql) {
|
||||||
setRowsExpected(1);
|
|
||||||
setDataSource(ds);
|
setDataSource(ds);
|
||||||
setSql(sql);
|
setSql(sql);
|
||||||
}
|
}
|
||||||
|
@ -90,9 +86,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
|
||||||
* {@code java.sql.Types} class
|
* {@code java.sql.Types} class
|
||||||
* @see java.sql.Types
|
* @see java.sql.Types
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public SqlFunction(DataSource ds, String sql, int[] types) {
|
public SqlFunction(DataSource ds, String sql, int[] types) {
|
||||||
setRowsExpected(1);
|
|
||||||
setDataSource(ds);
|
setDataSource(ds);
|
||||||
setSql(sql);
|
setSql(sql);
|
||||||
setTypes(types);
|
setTypes(types);
|
||||||
|
@ -108,9 +102,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
|
||||||
* @see #setResultType(Class)
|
* @see #setResultType(Class)
|
||||||
* @see java.sql.Types
|
* @see java.sql.Types
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public SqlFunction(DataSource ds, String sql, int[] types, Class<T> resultType) {
|
public SqlFunction(DataSource ds, String sql, int[] types, Class<T> resultType) {
|
||||||
setRowsExpected(1);
|
|
||||||
setDataSource(ds);
|
setDataSource(ds);
|
||||||
setSql(sql);
|
setSql(sql);
|
||||||
setTypes(types);
|
setTypes(types);
|
||||||
|
|
|
@ -57,10 +57,6 @@ import org.springframework.jdbc.core.namedparam.ParsedSql;
|
||||||
*/
|
*/
|
||||||
public abstract class SqlQuery<T> extends SqlOperation {
|
public abstract class SqlQuery<T> extends SqlOperation {
|
||||||
|
|
||||||
/** The number of rows to expect; if 0, unknown. */
|
|
||||||
private int rowsExpected = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to allow use as a JavaBean.
|
* Constructor to allow use as a JavaBean.
|
||||||
* <p>The {@code DataSource} and SQL must be supplied before
|
* <p>The {@code DataSource} and SQL must be supplied before
|
||||||
|
@ -81,29 +77,6 @@ public abstract class SqlQuery<T> extends SqlOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the number of rows expected.
|
|
||||||
* <p>This can be used to ensure efficient storage of results. The
|
|
||||||
* default behavior is not to expect any specific number of rows.
|
|
||||||
* @deprecated since 6.2.4 with no replacement since the property has never
|
|
||||||
* had any affect on behavior; to be removed in 7.0
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.2.4", forRemoval = true)
|
|
||||||
public void setRowsExpected(int rowsExpected) {
|
|
||||||
this.rowsExpected = rowsExpected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of rows expected.
|
|
||||||
* @deprecated since 6.2.4 with no replacement since the property has never
|
|
||||||
* had any affect on behavior; to be removed in 7.0
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.2.4", forRemoval = true)
|
|
||||||
public int getRowsExpected() {
|
|
||||||
return this.rowsExpected;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Central execution method. All un-named parameter execution goes through this method.
|
* Central execution method. All un-named parameter execution goes through this method.
|
||||||
* @param params parameters, similar to JDO query parameters.
|
* @param params parameters, similar to JDO query parameters.
|
||||||
|
|
|
@ -55,7 +55,6 @@ import static org.mockito.Mockito.verify;
|
||||||
*/
|
*/
|
||||||
class SqlQueryTests {
|
class SqlQueryTests {
|
||||||
|
|
||||||
// FIXME inline?
|
|
||||||
private static final String SELECT_ID =
|
private static final String SELECT_ID =
|
||||||
"select id from custmr";
|
"select id from custmr";
|
||||||
private static final String SELECT_ID_WHERE =
|
private static final String SELECT_ID_WHERE =
|
||||||
|
@ -163,13 +162,11 @@ class SqlQueryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("removal")
|
|
||||||
void testStringQueryWithResults() throws Exception {
|
void testStringQueryWithResults() throws Exception {
|
||||||
String[] dbResults = new String[] { "alpha", "beta", "charlie" };
|
String[] dbResults = new String[] { "alpha", "beta", "charlie" };
|
||||||
given(resultSet.next()).willReturn(true, true, true, false);
|
given(resultSet.next()).willReturn(true, true, true, false);
|
||||||
given(resultSet.getString(1)).willReturn(dbResults[0], dbResults[1], dbResults[2]);
|
given(resultSet.getString(1)).willReturn(dbResults[0], dbResults[1], dbResults[2]);
|
||||||
StringQuery query = new StringQuery(dataSource, SELECT_FORENAME);
|
StringQuery query = new StringQuery(dataSource, SELECT_FORENAME);
|
||||||
query.setRowsExpected(3);
|
|
||||||
String[] results = query.run();
|
String[] results = query.run();
|
||||||
assertThat(results).isEqualTo(dbResults);
|
assertThat(results).isEqualTo(dbResults);
|
||||||
verify(connection).prepareStatement(SELECT_FORENAME);
|
verify(connection).prepareStatement(SELECT_FORENAME);
|
||||||
|
|
Loading…
Reference in New Issue