SqlQuery::setRowsExpected
is invoked somewhere, but it make no sense since SqlQuery::getRowsExpected
is never invoked anywhere.
We have two options: 1. use it for query. 2. deprecate it for removal.
See GH-34502
Comment From: bclozel
I still don't get it. This is a java-bean style property on this class. While it's not being used in Spring Framework I think it's meant to be used by applications. Do you have any replacement for this to suggest for people using this?
This is not my area of expertise so I'll leave it to other team members to decide on this.
Comment From: quaff
Do you have any replacement for this to suggest for people using this?
I believe it's misused here, the intention of rowsExpected
is for performance consideration of creating ArrayList
, shouldn't rely on it.
If we decide to keep it, then we should use it for initialCapacity
of ArrayList
.
https://github.com/spring-projects/spring-framework/blob/03cce139377c8c100bac8ae55c1226248702441c/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowMapperResultSetExtractor.java#L90-L97
Comment From: sbrannen
Do you have any replacement for this to suggest for people using this?
I see it the same way as @quaff.
The rowsExpected
property cannot be relied on in any way. It is not used to enforce anything. Rather, it's only meant for potentially efficient storage in case the user knows in advance how many rows will be returned, as stated in the Javadoc for setRowsExpected()
.
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.
This is analogous to the rowsExpected
property of RowMapperResultSetExtractor
:
rowsExpected the number of expected rows (just used for optimized collection handling)
The difference is that rowsExpected
is used in RowMapperResultSetExtractor
, but it is not used in SqlQuery
.
Thus, as @quaff pointed out, with the status quo there is not much point in having rowsExpected
in SqlQuery
.
Comment From: jhoeller
Let's deprecate those methods for 6.2.4 if they don't have a clear purpose.