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 #compile
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public SqlFunction() {
|
||||
setRowsExpected(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,9 +73,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
|
|||
* @param ds the DataSource to obtain connections from
|
||||
* @param sql the SQL to execute
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public SqlFunction(DataSource ds, String sql) {
|
||||
setRowsExpected(1);
|
||||
setDataSource(ds);
|
||||
setSql(sql);
|
||||
}
|
||||
|
@ -90,9 +86,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
|
|||
* {@code java.sql.Types} class
|
||||
* @see java.sql.Types
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public SqlFunction(DataSource ds, String sql, int[] types) {
|
||||
setRowsExpected(1);
|
||||
setDataSource(ds);
|
||||
setSql(sql);
|
||||
setTypes(types);
|
||||
|
@ -108,9 +102,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
|
|||
* @see #setResultType(Class)
|
||||
* @see java.sql.Types
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public SqlFunction(DataSource ds, String sql, int[] types, Class<T> resultType) {
|
||||
setRowsExpected(1);
|
||||
setDataSource(ds);
|
||||
setSql(sql);
|
||||
setTypes(types);
|
||||
|
|
|
@ -57,10 +57,6 @@ import org.springframework.jdbc.core.namedparam.ParsedSql;
|
|||
*/
|
||||
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.
|
||||
* <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.
|
||||
* @param params parameters, similar to JDO query parameters.
|
||||
|
|
|
@ -55,7 +55,6 @@ import static org.mockito.Mockito.verify;
|
|||
*/
|
||||
class SqlQueryTests {
|
||||
|
||||
// FIXME inline?
|
||||
private static final String SELECT_ID =
|
||||
"select id from custmr";
|
||||
private static final String SELECT_ID_WHERE =
|
||||
|
@ -163,13 +162,11 @@ class SqlQueryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void testStringQueryWithResults() throws Exception {
|
||||
String[] dbResults = new String[] { "alpha", "beta", "charlie" };
|
||||
given(resultSet.next()).willReturn(true, true, true, false);
|
||||
given(resultSet.getString(1)).willReturn(dbResults[0], dbResults[1], dbResults[2]);
|
||||
StringQuery query = new StringQuery(dataSource, SELECT_FORENAME);
|
||||
query.setRowsExpected(3);
|
||||
String[] results = query.run();
|
||||
assertThat(results).isEqualTo(dbResults);
|
||||
verify(connection).prepareStatement(SELECT_FORENAME);
|
||||
|
|
Loading…
Reference in New Issue