Skip to content

Commit 10bd9c5

Browse files
committed
Deprecate unused "rowsExpected" of SqlQuery for removal
Fix GH-34512 Signed-off-by: Yanming Zhou <[email protected]>
1 parent 382caac commit 10bd9c5

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -65,7 +65,6 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
6565
* @see #compile
6666
*/
6767
public SqlFunction() {
68-
setRowsExpected(1);
6968
}
7069

7170
/**
@@ -75,7 +74,6 @@ public SqlFunction() {
7574
* @param sql the SQL to execute
7675
*/
7776
public SqlFunction(DataSource ds, String sql) {
78-
setRowsExpected(1);
7977
setDataSource(ds);
8078
setSql(sql);
8179
}
@@ -89,7 +87,6 @@ public SqlFunction(DataSource ds, String sql) {
8987
* @see java.sql.Types
9088
*/
9189
public SqlFunction(DataSource ds, String sql, int[] types) {
92-
setRowsExpected(1);
9390
setDataSource(ds);
9491
setSql(sql);
9592
setTypes(types);
@@ -106,7 +103,6 @@ public SqlFunction(DataSource ds, String sql, int[] types) {
106103
* @see java.sql.Types
107104
*/
108105
public SqlFunction(DataSource ds, String sql, int[] types, Class<T> resultType) {
109-
setRowsExpected(1);
110106
setDataSource(ds);
111107
setSql(sql);
112108
setTypes(types);

spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java

+6
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,20 @@ public SqlQuery(DataSource ds, String sql) {
8585
* Set the number of rows expected.
8686
* <p>This can be used to ensure efficient storage of results. The
8787
* default behavior is not to expect any specific number of rows.
88+
*
89+
* @deprecated since 6.2.4 with no replacement; it's for internal use only
8890
*/
91+
@Deprecated(since = "6.2.4", forRemoval = true)
8992
public void setRowsExpected(int rowsExpected) {
9093
this.rowsExpected = rowsExpected;
9194
}
9295

9396
/**
9497
* Get the number of rows expected.
98+
*
99+
* @deprecated since 6.2.4 with no replacement; it's for internal use only
95100
*/
101+
@Deprecated(since = "6.2.4", forRemoval = true)
96102
public int getRowsExpected() {
97103
return this.rowsExpected;
98104
}

spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -168,7 +168,6 @@ void testStringQueryWithResults() throws Exception {
168168
given(resultSet.next()).willReturn(true, true, true, false);
169169
given(resultSet.getString(1)).willReturn(dbResults[0], dbResults[1], dbResults[2]);
170170
StringQuery query = new StringQuery(dataSource, SELECT_FORENAME);
171-
query.setRowsExpected(3);
172171
String[] results = query.run();
173172
assertThat(results).isEqualTo(dbResults);
174173
verify(connection).prepareStatement(SELECT_FORENAME);

0 commit comments

Comments
 (0)