From 78cc5df748ba5227c6e262ebc3ff55b5bac498c0 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Thu, 27 Feb 2025 11:02:59 +0800 Subject: [PATCH 1/2] Deprecate unused "rowsExpected" property of SqlQuery for removal See gh-34526 Signed-off-by: Yanming Zhou --- .../main/java/org/springframework/jdbc/object/SqlQuery.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 170771928ec..f30426ac76e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -84,14 +84,18 @@ 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; it's for internal use only */ + @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; it's for internal use only */ + @Deprecated(since = "6.2.4", forRemoval = true) public int getRowsExpected() { return this.rowsExpected; } From 30d793cefed89215abaf06f71620867908961091 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:32:52 +0100 Subject: [PATCH 2/2] Revise deprecation of SqlQuery.rowsExpected Closes gh-34526 --- .../java/org/springframework/jdbc/object/SqlFunction.java | 6 +++++- .../main/java/org/springframework/jdbc/object/SqlQuery.java | 6 ++++-- .../java/org/springframework/jdbc/object/SqlQueryTests.java | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) 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 59408ac658a..db33723bcd6 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. @@ -63,6 +63,7 @@ public class SqlFunction extends MappingSqlQuery { * @see #setSql * @see #compile */ + @SuppressWarnings("removal") public SqlFunction() { setRowsExpected(1); } @@ -73,6 +74,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); @@ -87,6 +89,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); @@ -104,6 +107,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 f30426ac76e..994329c3202 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 @@ -84,7 +84,8 @@ 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; 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 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() { 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 1a525815aa5..372ed627cb9 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);