Revise deprecation of SqlQuery.rowsExpected

Closes gh-34526
This commit is contained in:
Sam Brannen
2025-03-03 14:32:52 +01:00
parent 78cc5df748
commit 30d793cefe
3 changed files with 11 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,6 +63,7 @@ public class SqlFunction<T> extends MappingSqlQuery<T> {
* @see #setSql
* @see #compile
*/
@SuppressWarnings("removal")
public SqlFunction() {
setRowsExpected(1);
}
@@ -73,6 +74,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);
@@ -87,6 +89,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);
@@ -104,6 +107,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);

View File

@@ -84,7 +84,8 @@ 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; it's for internal use only
* @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) {
@@ -93,7 +94,8 @@ public abstract class SqlQuery<T> extends SqlOperation {
/**
* Get the number of rows expected.
* @deprecated since 6.2.4 with no replacement; it's for internal use only
* @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() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -163,6 +163,7 @@ class SqlQueryTests {
}
@Test
@SuppressWarnings("removal")
void testStringQueryWithResults() throws Exception {
String[] dbResults = new String[] { "alpha", "beta", "charlie" };
given(resultSet.next()).willReturn(true, true, true, false);