diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java index c9be8bd09e7..43f388be44b 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java @@ -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. @@ -64,6 +64,7 @@ public class SqlFunction extends MappingSqlQuery { * @see #setSql * @see #compile */ + @SuppressWarnings("removal") public SqlFunction() { setRowsExpected(1); } @@ -74,6 +75,7 @@ public class SqlFunction extends MappingSqlQuery { * @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); @@ -88,6 +90,7 @@ public class SqlFunction extends MappingSqlQuery { * {@code java.sql.Types} class * @see java.sql.Types */ + @SuppressWarnings("removal") public SqlFunction(DataSource ds, String sql, int[] types) { setRowsExpected(1); setDataSource(ds); @@ -105,6 +108,7 @@ public class SqlFunction extends MappingSqlQuery { * @see #setResultType(Class) * @see java.sql.Types */ + @SuppressWarnings("removal") public SqlFunction(DataSource ds, String sql, int[] types, Class resultType) { setRowsExpected(1); setDataSource(ds); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java index 88084cc62d4..39ded59e1ea 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java @@ -85,14 +85,20 @@ public abstract class SqlQuery extends SqlOperation { * Set the number of rows expected. *

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; } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java index 2af6f993223..7de84342833 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java @@ -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);